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