• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //          Copyright Alain Miniussi 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors: Alain Miniussi
7 
8 #ifndef BOOST_MPI_ANTIQUES_HPP
9 #define BOOST_MPI_ANTIQUES_HPP
10 
11 #include <vector>
12 
13 // Support for some obsolette compilers
14 
15 namespace boost { namespace mpi {
16 namespace detail {
17   // Some old gnu compiler have no support for vector<>::data
18   // Use this in the mean time, the cumbersome syntax should
19   // serve as an incentive to get rid of this when those compilers
20   // are dropped.
21   template <typename T, typename A>
c_data(std::vector<T,A> & v)22   T* c_data(std::vector<T,A>& v) { return v.empty() ? static_cast<T*>(0) : &(v[0]); }
23 
24   template <typename T, typename A>
c_data(std::vector<T,A> const & v)25   T const* c_data(std::vector<T,A> const& v) { return v.empty() ? static_cast<T const*>(0) : &(v[0]); }
26 
27   // Some old MPI implementation (OpenMPI 1.6 for example) have non
28   // conforming API w.r.t. constness.
29   // We choose to fix this trhough this converter in order to
30   // explain/remember why we're doing this and remove it easilly
31   // when support for those MPI is dropped.
32   // The fix is as specific (un templatized, for one) as possible
33   // in order to encourage it usage for the probleme at hand.
34   // Problematic API include MPI_Send
35   inline
unconst(void const * addr)36   void *unconst(void const* addr) { return const_cast<void*>(addr); }
37 
38 } } }
39 
40 #endif
41