• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  [auto_generated]
3  boost/numeric/odeint/util/state_wrapper.hpp
4 
5  [begin_description]
6  State wrapper for the state type in all stepper. The state wrappers are responsible for construction,
7  destruction, copying construction, assignment and resizing.
8  [end_description]
9 
10  Copyright 2011-2013 Karsten Ahnert
11  Copyright 2011 Mario Mulansky
12 
13  Distributed under the Boost Software License, Version 1.0.
14  (See accompanying file LICENSE_1_0.txt or
15  copy at http://www.boost.org/LICENSE_1_0.txt)
16  */
17 
18 
19 #ifndef BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
20 #define BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
21 
22 #include <boost/range.hpp>
23 
24 #include <boost/utility/enable_if.hpp>
25 #include <boost/fusion/include/is_sequence.hpp>
26 #include <boost/fusion/include/zip_view.hpp>
27 #include <boost/fusion/include/vector.hpp>
28 #include <boost/fusion/include/make_fused.hpp>
29 #include <boost/fusion/include/for_each.hpp>
30 
31 #include <boost/numeric/odeint/util/is_resizeable.hpp>
32 
33 namespace boost {
34 namespace numeric {
35 namespace odeint {
36 
37 
38 template< class StateOut , class StateIn , class Enabler = void >
39 struct resize_impl_sfinae
40 {
resizeboost::numeric::odeint::resize_impl_sfinae41     static void resize( StateOut &x1 , const StateIn &x2 )
42     {
43         x1.resize( boost::size( x2 ) );
44     }
45 };
46 
47 // resize function
48 // standard implementation relies on boost.range and resize member function
49 template< class StateOut , class StateIn >
50 struct resize_impl
51 {
resizeboost::numeric::odeint::resize_impl52     static void resize( StateOut &x1 , const StateIn &x2 )
53     {
54         resize_impl_sfinae< StateOut , StateIn >::resize( x1 , x2 );
55     }
56 };
57 
58 
59 // do not overload or specialize this function, specialize resize_impl<> instead
60 template< class StateOut , class StateIn >
resize(StateOut & x1,const StateIn & x2)61 void resize( StateOut &x1 , const StateIn &x2 )
62 {
63     resize_impl< StateOut , StateIn >::resize( x1 , x2 );
64 }
65 
66 
67 namespace detail {
68 
69     struct resizer
70     {
71         typedef void result_type;
72 
73         template< class StateOut , class StateIn >
operator ()boost::numeric::odeint::detail::resizer74         void operator()( StateOut &x1 , const StateIn &x2 ) const
75         {
76             resize_op( x1 , x2 , typename is_resizeable< StateOut >::type() );
77         }
78 
79         template< class StateOut , class StateIn >
resize_opboost::numeric::odeint::detail::resizer80         void resize_op( StateOut &x1 , const StateIn &x2 , boost::true_type ) const
81         {
82             resize( x1 , x2 );
83         }
84 
85         template< class StateOut , class StateIn >
resize_opboost::numeric::odeint::detail::resizer86         void resize_op( StateOut &/*x1*/ , const StateIn &/*x2*/ , boost::false_type ) const
87         {
88         }
89 
90     };
91 } // namespace detail
92 
93 
94 /*
95  * specialization for fusion sequences
96  */
97 template< class FusionSeq >
98 struct resize_impl_sfinae< FusionSeq , FusionSeq ,
99     typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
100 {
resizeboost::numeric::odeint::resize_impl_sfinae101     static void resize( FusionSeq &x1 , const FusionSeq &x2 )
102     {
103         typedef boost::fusion::vector< FusionSeq& , const FusionSeq& > Sequences;
104         Sequences sequences( x1 , x2 );
105         boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( detail::resizer() ) );
106     }
107 };
108 
109 
110 
111 
112 }
113 }
114 }
115 
116 
117 
118 #endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZE_HPP_INCLUDED
119