Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Function template get_mpi_datatype

boost::mpi::get_mpi_datatype — Returns an MPI data type for a C++ type.


// In header: <boost/mpi/datatype.hpp>

template<typename T> MPI_Datatype get_mpi_datatype(const T & x);


The function creates an MPI data type for the given object x. The first time it is called for a class T, the MPI data type is created and cached. Subsequent calls for objects of the same type T return the cached MPI data type. The type T must allow creation of an MPI data type. That is, it must be Serializable and is_mpi_datatype<T> must derive mpl::true_.

For fundamental MPI types, a copy of the MPI data type of the MPI library is returned.

Note that since the data types are cached, the caller should never call MPI_Type_free() for the MPI data type returned by this call.



for an optimized call, a constructed object of the type should be passed; otherwise, an object will be default-constructed.


The MPI data type corresponding to type T.