]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/mpi/inplace.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / mpi / inplace.hpp
CommitLineData
7c673cae
FG
1// Copyright (C) 2005-2006 Alain Miniussi <alain.miniussi -at- oca.eu>.
2
3// Use, modification and distribution is subject to the Boost Software
4// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7// Message Passing Interface 1.1 -- Section 4. MPI Collectives
8
9/** @file inplace.hpp
10 *
11 * This header provides helpers to indicate to MPI collective operation
12 * that a buffer can be use both as an input and output.
13 */
14#ifndef BOOST_MPI_INPLACE_HPP
15#define BOOST_MPI_INPLACE_HPP
16
17#include <boost/mpi/communicator.hpp>
18#include <vector>
19
20namespace boost { namespace mpi {
21
22/**
23 * @brief Wrapper type to explicitly indicate that a input data
24 * can be overriden with an output value.
25 */
26template <typename T>
27struct inplace_t {
28 inplace_t(T& inout) : buffer(inout) {}
29 T& buffer;
30};
31
32template <typename T>
33struct inplace_t<T*> {
34 inplace_t(T* inout) : buffer(inout) {}
35 T* buffer;
36};
37
38
39/**
40 * @brief Wrapp a input data to indicate that it can be overriden
41 * with an ouput value.
42 * @param inout the contributing input value, it will be overriden
43 * with the output value where one is expected. If it is a pointer,
44 * the number of elements will be provided separatly.
45 * @returns The wrapped value or pointer.
46 */
47template<typename T>
48inplace_t<T>
49inplace(T& inout) {
50 return inplace_t<T>(inout);
51}
52/**
53 * \overload
54 */
55template<typename T>
56inplace_t<T*>
57inplace(T* inout) {
58 return inplace_t<T*>(inout);
59}
60} } // end namespace boost::mpi
61
62#endif // BOOST_MPI_INPLACE_HPP
63