| Home | Libraries | People | FAQ | More

## Function template get_mpi_datatype

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

## Synopsis

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

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

## Description

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.

Parameters: |

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

Returns: | The MPI data type corresponding to type `T`.