Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:21:47

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/util/copy.hpp
0004 
0005  [begin_description]
0006  Copy abstraction for the usage in the steppers.
0007  [end_description]
0008 
0009  Copyright 2011-2012 Karsten Ahnert
0010  Copyright 2011-2012 Mario Mulansky
0011 
0012  Distributed under the Boost Software License, Version 1.0.
0013  (See accompanying file LICENSE_1_0.txt or
0014  copy at http://www.boost.org/LICENSE_1_0.txt)
0015  */
0016 
0017 
0018 #ifndef BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED
0020 
0021 #include <type_traits>
0022 
0023 #include <boost/range/algorithm/copy.hpp>
0024 
0025 #include <boost/utility/enable_if.hpp>
0026 
0027 #include <boost/numeric/odeint/util/detail/is_range.hpp>
0028 
0029 namespace boost {
0030 namespace numeric {
0031 namespace odeint {
0032 
0033 namespace detail {
0034 
0035     template< class Container1 , class Container2 >
0036     void do_copying( const Container1 &from , Container2 &to , std::integral_constant<bool, true>)
0037     {
0038         boost::range::copy( from , boost::begin( to ) );
0039     }
0040 
0041     template< class Container1 , class Container2 >
0042     void do_copying( const Container1 &from , Container2 &to , std::integral_constant<bool, false>)
0043     {
0044         to = from;
0045     }
0046 
0047 } // namespace detail
0048 
0049 
0050 
0051 /*
0052  * Default implementation of the copy operation used the assign operator
0053  * gsl_vector must copied differently
0054  */
0055 template< class Container1 , class Container2 , class Enabler = void >
0056 struct copy_impl_sfinae
0057 {
0058     static void copy( const Container1 &from , Container2 &to )
0059     {
0060         typedef typename boost::numeric::odeint::detail::is_range< Container1 >::type is_range_type;
0061         detail::do_copying( from , to , is_range_type() );
0062     }
0063 
0064 };
0065 
0066 template< class Container1, class Container2 >
0067 struct copy_impl
0068 {
0069     static void copy( const Container1 &from , Container2 &to )
0070     {
0071         copy_impl_sfinae< Container1 , Container2 >::copy( from , to );
0072     }
0073 };
0074 
0075 // ToDo: allow also to copy INTO a range, not only from a range! Needs "const Container2 &to"
0076 template< class Container1 , class Container2 >
0077 void copy( const Container1 &from , Container2 &to )
0078 {
0079     copy_impl< Container1 , Container2 >::copy( from , to );
0080 }
0081 
0082 
0083 } // namespace odeint
0084 } // namespace numeric
0085 } // namespace boost
0086 
0087 
0088 #endif // BOOST_NUMERIC_ODEINT_UTIL_COPY_HPP_INCLUDED