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_SAME_SIZE_HPP_INCLUDED
20 #define BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
21 
22 #include <boost/numeric/odeint/util/is_resizeable.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/all.hpp>
30 
31 #include <boost/range.hpp>
32 
33 
34 namespace boost {
35 namespace numeric {
36 namespace odeint {
37 
38 template< typename State1 , typename State2 , class Enabler = void >
39 struct same_size_impl_sfinae
40 {
same_sizeboost::numeric::odeint::same_size_impl_sfinae41     static bool same_size( const State1 &x1 , const State2 &x2 )
42     {
43         return ( boost::size( x1 ) == boost::size( x2 ) );
44     }
45 
46 };
47 
48 // same_size function
49 // standard implementation relies on boost.range
50 template< class State1 , class State2 >
51 struct same_size_impl
52 {
same_sizeboost::numeric::odeint::same_size_impl53     static bool same_size( const State1 &x1 , const State2 &x2 )
54     {
55         return same_size_impl_sfinae< State1 , State2 >::same_size( x1 , x2 );
56     }
57 };
58 
59 
60 // do not overload or specialize this function, specialize resize_impl<> instead
61 template< class State1 , class State2 >
same_size(const State1 & x1,const State2 & x2)62 bool same_size( const State1 &x1 , const State2 &x2 )
63 {
64     return same_size_impl< State1 , State2 >::same_size( x1 , x2 );
65 }
66 
67 namespace detail {
68 
69 struct same_size_fusion
70 {
71     typedef bool result_type;
72 
73     template< class S1 , class S2 >
operator ()boost::numeric::odeint::detail::same_size_fusion74     bool operator()( const S1 &x1 , const S2 &x2 ) const
75     {
76         return same_size_op( x1 , x2 , typename is_resizeable< S1 >::type() );
77     }
78 
79     template< class S1 , class S2 >
same_size_opboost::numeric::odeint::detail::same_size_fusion80     bool same_size_op( const S1 &x1 , const S2 &x2 , boost::true_type ) const
81     {
82         return same_size( x1 , x2 );
83     }
84 
85     template< class S1 , class S2 >
same_size_opboost::numeric::odeint::detail::same_size_fusion86     bool same_size_op( const S1 &/*x1*/ , const S2 &/*x2*/ , boost::false_type ) const
87     {
88         return true;
89     }
90 };
91 
92 } // namespace detail
93 
94 
95 
96 template< class FusionSeq >
97 struct same_size_impl_sfinae< FusionSeq , FusionSeq , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
98 {
same_sizeboost::numeric::odeint::same_size_impl_sfinae99     static bool same_size( const FusionSeq &x1 , const FusionSeq &x2 )
100     {
101         typedef boost::fusion::vector< const FusionSeq& , const FusionSeq& > Sequences;
102         Sequences sequences( x1 , x2 );
103         return boost::fusion::all( boost::fusion::zip_view< Sequences >( sequences ) ,
104                                    boost::fusion::make_fused( detail::same_size_fusion() ) );
105     }
106 };
107 
108 
109 }
110 }
111 }
112 
113 
114 
115 #endif // BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
116