mirror of
https://github.com/boostorg/odeint.git
synced 2025-05-09 23:24:01 +00:00
adding two level specialization for is_resizeable
This commit is contained in:
parent
a997d074c1
commit
d0257efa4a
@ -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;
|
||||
|
@ -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 );
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user