copy.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <boost/range/algorithm/copy.hpp>
  16. #include <boost/utility/enable_if.hpp>
  17. #include <boost/numeric/odeint/util/detail/is_range.hpp>
  18. namespace boost {
  19. namespace numeric {
  20. namespace odeint {
  21. namespace detail {
  22. template< class Container1 , class Container2 >
  23. void do_copying( const Container1 &from , Container2 &to , boost::mpl::true_ )
  24. {
  25. boost::range::copy( from , boost::begin( to ) );
  26. }
  27. template< class Container1 , class Container2 >
  28. void do_copying( const Container1 &from , Container2 &to , boost::mpl::false_ )
  29. {
  30. to = from;
  31. }
  32. } // namespace detail
  33. /*
  34. * Default implementation of the copy operation used the assign operator
  35. * gsl_vector must copied differently
  36. */
  37. template< class Container1 , class Container2 , class Enabler = void >
  38. struct copy_impl_sfinae
  39. {
  40. static void copy( const Container1 &from , Container2 &to )
  41. {
  42. typedef typename boost::numeric::odeint::detail::is_range< Container1 >::type is_range_type;
  43. detail::do_copying( from , to , is_range_type() );
  44. }
  45. };
  46. template< class Container1, class Container2 >
  47. struct copy_impl
  48. {
  49. static void copy( const Container1 &from , Container2 &to )
  50. {
  51. copy_impl_sfinae< Container1 , Container2 >::copy( from , to );
  52. }
  53. };
  54. // ToDo: allow also to copy INTO a range, not only from a range! Needs "const Container2 &to"
  55. template< class Container1 , class Container2 >
  56. void copy( const Container1 &from , Container2 &to )
  57. {
  58. copy_impl< Container1 , Container2 >::copy( from , to );
  59. }
  60. } // namespace odeint
  61. } // namespace numeric
  62. } // namespace boost
  63. #endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED