copy.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/util/copy.hpp
  4. [begin_description]
  5. Copy abstraction for the usage in the steppers.
  6. [end_description]
  7. Copyright 2011-2012 Karsten Ahnert
  8. Copyright 2011-2012 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
  15. #include <type_traits>
  16. #include <boost/range/algorithm/copy.hpp>
  17. #include <boost/utility/enable_if.hpp>
  18. #include <boost/numeric/odeint/util/detail/is_range.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. namespace detail {
  23. template< class Container1 , class Container2 >
  24. void do_copying( const Container1 &from , Container2 &to , std::integral_constant<bool, true>)
  25. {
  26. boost::range::copy( from , boost::begin( to ) );
  27. }
  28. template< class Container1 , class Container2 >
  29. void do_copying( const Container1 &from , Container2 &to , std::integral_constant<bool, false>)
  30. {
  31. to = from;
  32. }
  33. } // namespace detail
  34. /*
  35. * Default implementation of the copy operation used the assign operator
  36. * gsl_vector must copied differently
  37. */
  38. template< class Container1 , class Container2 , class Enabler = void >
  39. struct copy_impl_sfinae
  40. {
  41. static void copy( const Container1 &from , Container2 &to )
  42. {
  43. typedef typename boost::numeric::odeint::detail::is_range< Container1 >::type is_range_type;
  44. detail::do_copying( from , to , is_range_type() );
  45. }
  46. };
  47. template< class Container1, class Container2 >
  48. struct copy_impl
  49. {
  50. static void copy( const Container1 &from , Container2 &to )
  51. {
  52. copy_impl_sfinae< Container1 , Container2 >::copy( from , to );
  53. }
  54. };
  55. // ToDo: allow also to copy INTO a range, not only from a range! Needs "const Container2 &to"
  56. template< class Container1 , class Container2 >
  57. void copy( const Container1 &from , Container2 &to )
  58. {
  59. copy_impl< Container1 , Container2 >::copy( from , to );
  60. }
  61. } // namespace odeint
  62. } // namespace numeric
  63. } // namespace boost
  64. #endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED