antiques.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // Authors: Alain Miniussi
  6. #ifndef BOOST_MPI_ANTIQUES_HPP
  7. #define BOOST_MPI_ANTIQUES_HPP
  8. #include <vector>
  9. // Support for some obsolette compilers
  10. namespace boost { namespace mpi {
  11. namespace detail {
  12. // Some old gnu compiler have no support for vector<>::data
  13. // Use this in the mean time, the cumbersome syntax should
  14. // serve as an incentive to get rid of this when those compilers
  15. // are dropped.
  16. template <typename T, typename A>
  17. T* c_data(std::vector<T,A>& v) { return v.empty() ? static_cast<T*>(0) : &(v[0]); }
  18. template <typename T, typename A>
  19. T const* c_data(std::vector<T,A> const& v) { return v.empty() ? static_cast<T const*>(0) : &(v[0]); }
  20. // Some old MPI implementation (OpenMPI 1.6 for example) have non
  21. // conforming API w.r.t. constness.
  22. // We choose to fix this trhough this converter in order to
  23. // explain/remember why we're doing this and remove it easilly
  24. // when support for those MPI is dropped.
  25. // The fix is as specific (un templatized, for one) as possible
  26. // in order to encourage it usage for the probleme at hand.
  27. // Problematic API include MPI_Send
  28. inline
  29. void *unconst(void const* addr) { return const_cast<void*>(addr); }
  30. } } }
  31. #endif