bind.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * [begin_description]
  3. * Boost bind pull the placeholders, _1, _2, ... into global
  4. * namespace. This can conflict with the C++03 TR1 and C++11
  5. * std::placeholders. This header provides a workaround for
  6. * this problem.
  7. * [end_description]
  8. *
  9. * Copyright 2012 Christoph Koke
  10. * Copyright 2012 Karsten Ahnert
  11. *
  12. * Distributed under the Boost Software License, Version 1.0.
  13. * (See accompanying file LICENSE_1_0.txt or
  14. * copy at http://www.boost.org/LICENSE_1_0.txt)
  15. * */
  16. #ifndef BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
  17. #define BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED
  18. #include <boost/numeric/odeint/config.hpp>
  19. #if BOOST_NUMERIC_ODEINT_CXX11
  20. #include <functional>
  21. #else
  22. #define BOOST_BIND_NO_PLACEHOLDERS
  23. #include <boost/bind.hpp>
  24. #endif
  25. namespace boost {
  26. namespace numeric {
  27. namespace odeint {
  28. namespace detail {
  29. #if BOOST_NUMERIC_ODEINT_CXX11
  30. using ::std::bind;
  31. using namespace ::std::placeholders;
  32. #else
  33. // unnamed namespace to avoid multiple declarations (#138)
  34. namespace {
  35. using ::boost::bind;
  36. boost::arg<1> _1;
  37. boost::arg<2> _2;
  38. }
  39. // using ::boost::bind;
  40. // using ::_1;
  41. // using ::_2;
  42. #endif
  43. }
  44. }
  45. }
  46. }
  47. /*
  48. // the following is the suggested way. Unfortunately it does not work with all compilers.
  49. #ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
  50. #include <boost/bind.hpp>
  51. #else
  52. #include <functional>
  53. #endif
  54. namespace boost {
  55. namespace numeric {
  56. namespace odeint {
  57. namespace detail {
  58. #ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL
  59. using ::boost::bind;
  60. using ::_1;
  61. using ::_2;
  62. #else
  63. using ::std::bind;
  64. using namespace ::std::placeholders;
  65. #endif
  66. }
  67. }
  68. }
  69. }*/
  70. #endif // BOOST_NUMERIC_ODEINT_UTIL_BIND_HPP_INCLUDED