blob: 161f135534783c9c08d55d1d95e278a66883c326 [file] [log] [blame]
Brian Silverman7c33ab22018-08-04 17:14:51 -07001/*
2 [auto_generated]
3 boost/numeric/odeint/util/copy.hpp
4
5 [begin_description]
6 Copy abstraction for the usage in the steppers.
7 [end_description]
8
9 Copyright 2011-2012 Karsten Ahnert
10 Copyright 2011-2012 Mario Mulansky
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
17
18#ifndef BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
19#define BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
20
21
22#include <boost/range/algorithm/copy.hpp>
23
24#include <boost/utility/enable_if.hpp>
25
26#include <boost/numeric/odeint/util/detail/is_range.hpp>
27
28namespace boost {
29namespace numeric {
30namespace odeint {
31
32namespace detail {
33
34 template< class Container1 , class Container2 >
35 void do_copying( const Container1 &from , Container2 &to , boost::mpl::true_ )
36 {
37 boost::range::copy( from , boost::begin( to ) );
38 }
39
40 template< class Container1 , class Container2 >
41 void do_copying( const Container1 &from , Container2 &to , boost::mpl::false_ )
42 {
43 to = from;
44 }
45
46} // namespace detail
47
48
49
50/*
51 * Default implementation of the copy operation used the assign operator
52 * gsl_vector must copied differently
53 */
54template< class Container1 , class Container2 , class Enabler = void >
55struct copy_impl_sfinae
56{
57 static void copy( const Container1 &from , Container2 &to )
58 {
59 typedef typename boost::numeric::odeint::detail::is_range< Container1 >::type is_range_type;
60 detail::do_copying( from , to , is_range_type() );
61 }
62
63};
64
65template< class Container1, class Container2 >
66struct copy_impl
67{
68 static void copy( const Container1 &from , Container2 &to )
69 {
70 copy_impl_sfinae< Container1 , Container2 >::copy( from , to );
71 }
72};
73
74// ToDo: allow also to copy INTO a range, not only from a range! Needs "const Container2 &to"
75template< class Container1 , class Container2 >
76void copy( const Container1 &from , Container2 &to )
77{
78 copy_impl< Container1 , Container2 >::copy( from , to );
79}
80
81
82} // namespace odeint
83} // namespace numeric
84} // namespace boost
85
86
87#endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED