diff --git a/include/boost/numeric/odeint/util/is_resizeable.hpp b/include/boost/numeric/odeint/util/is_resizeable.hpp index 209411e8..d0878227 100644 --- a/include/boost/numeric/odeint/util/is_resizeable.hpp +++ b/include/boost/numeric/odeint/util/is_resizeable.hpp @@ -36,35 +36,44 @@ namespace boost { namespace numeric { namespace odeint { + +template< typename Container , typename Enabler = void > +struct is_resizeable_sfinae : boost::false_type {}; -/* - * by default any type is not resizable - */ -template< class Container , class Enabler = void > -struct is_resizeable -{ - //struct type : public boost::false_type { }; - typedef boost::false_type type; - const static bool value = type::value; -}; +template< typename Container > +struct is_resizeable : is_resizeable_sfinae< Container > {}; + + +// /* +// * by default any type is not resizable +// */ +// template< class Container , class Enabler = void > +// struct is_resizeable +// { +// //struct type : public boost::false_type { }; +// typedef boost::false_type type; +// const static bool value = type::value; +// }; /* * specialization for std::vector */ template< class V, class A > -struct is_resizeable< std::vector< V , A > > -{ - //struct type : public boost::true_type { }; - typedef boost::true_type type; - const static bool value = type::value; -}; +struct is_resizeable< std::vector< V , A > > : boost::true_type {}; +// { +// //struct type : public boost::true_type { }; +// typedef boost::true_type type; +// const static bool value = type::value; +// }; /* * specialization for fusion sequences */ -template< class FusionSequence > -struct is_resizeable< FusionSequence , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type > +template< typename FusionSequence > +struct is_resizeable_sfinae< + FusionSequence , + typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type > { typedef typename boost::mpl::find_if< FusionSequence , is_resizeable< boost::mpl::_1 > >::type iter; typedef typename boost::mpl::end< FusionSequence >::type last; diff --git a/test/is_resizeable.cpp b/test/is_resizeable.cpp index 0cbaa7f0..cb8e9c1c 100644 --- a/test/is_resizeable.cpp +++ b/test/is_resizeable.cpp @@ -39,6 +39,24 @@ using namespace boost::unit_test; using namespace boost::numeric::odeint; +template< typename T > struct my_seq1 {}; +template< typename T > struct my_seq2 {}; + +namespace boost { namespace fusion { namespace traits { + + template< typename T > struct is_sequence< my_seq1< T > > : boost::true_type {}; + template< typename T > struct is_sequence< my_seq2< T > > : boost::true_type {}; +} } } // boost::fusion::traits + +namespace boost { namespace numeric { namespace odeint { + + template< typename T > + struct is_resizeable< my_seq2< T > > : boost::true_type {}; + +} } } // boost::numeric::odeint + + + BOOST_AUTO_TEST_CASE( test_vector ) { BOOST_CHECK( is_resizeable< std::vector< int > >::value ); @@ -86,3 +104,13 @@ BOOST_AUTO_TEST_CASE( test_fusion_quantity_sequence ) BOOST_CHECK( !( is_resizeable< state_type >::value ) ); } + +BOOST_AUTO_TEST_CASE( test_my_seq1 ) +{ + BOOST_CHECK( !is_resizeable< my_seq1< double > >::value ); +} + +BOOST_AUTO_TEST_CASE( test_my_seq2 ) +{ + BOOST_CHECK( is_resizeable< my_seq2< double > >::value ); +} \ No newline at end of file