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