File indexing completed on 2025-01-18 09:42:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
0020 #define BOOST_NUMERIC_ODEINT_UTIL_SAME_SIZE_HPP_INCLUDED
0021
0022 #include <boost/numeric/odeint/util/is_resizeable.hpp>
0023
0024 #include <boost/utility/enable_if.hpp>
0025 #include <boost/fusion/include/is_sequence.hpp>
0026 #include <boost/fusion/include/zip_view.hpp>
0027 #include <boost/fusion/include/vector.hpp>
0028 #include <boost/fusion/include/make_fused.hpp>
0029 #include <boost/fusion/include/all.hpp>
0030
0031 #include <boost/range.hpp>
0032
0033
0034 namespace boost {
0035 namespace numeric {
0036 namespace odeint {
0037
0038 template< typename State1 , typename State2 , class Enabler = void >
0039 struct same_size_impl_sfinae
0040 {
0041 static bool same_size( const State1 &x1 , const State2 &x2 )
0042 {
0043 return ( boost::size( x1 ) == boost::size( x2 ) );
0044 }
0045
0046 };
0047
0048
0049
0050 template< class State1 , class State2 >
0051 struct same_size_impl
0052 {
0053 static bool same_size( const State1 &x1 , const State2 &x2 )
0054 {
0055 return same_size_impl_sfinae< State1 , State2 >::same_size( x1 , x2 );
0056 }
0057 };
0058
0059
0060
0061 template< class State1 , class State2 >
0062 bool same_size( const State1 &x1 , const State2 &x2 )
0063 {
0064 return same_size_impl< State1 , State2 >::same_size( x1 , x2 );
0065 }
0066
0067 namespace detail {
0068
0069 struct same_size_fusion
0070 {
0071 typedef bool result_type;
0072
0073 template< class S1 , class S2 >
0074 bool operator()( const S1 &x1 , const S2 &x2 ) const
0075 {
0076 return same_size_op( x1 , x2 , typename is_resizeable< S1 >::type() );
0077 }
0078
0079 template< class S1 , class S2 >
0080 bool same_size_op( const S1 &x1 , const S2 &x2 , boost::true_type ) const
0081 {
0082 return same_size( x1 , x2 );
0083 }
0084
0085 template< class S1 , class S2 >
0086 bool same_size_op( const S1 & , const S2 & , boost::false_type ) const
0087 {
0088 return true;
0089 }
0090 };
0091
0092 }
0093
0094
0095
0096 template< class FusionSeq >
0097 struct same_size_impl_sfinae< FusionSeq , FusionSeq , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSeq >::type >::type >
0098 {
0099 static bool same_size( const FusionSeq &x1 , const FusionSeq &x2 )
0100 {
0101 typedef boost::fusion::vector< const FusionSeq& , const FusionSeq& > Sequences;
0102 Sequences sequences( x1 , x2 );
0103 return boost::fusion::all( boost::fusion::zip_view< Sequences >( sequences ) ,
0104 boost::fusion::make_fused( detail::same_size_fusion() ) );
0105 }
0106 };
0107
0108
0109 }
0110 }
0111 }
0112
0113
0114
0115 #endif