mirror of
https://github.com/boostorg/odeint.git
synced 2025-05-11 13:34:09 +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 boost {
|
||||||
namespace numeric {
|
namespace numeric {
|
||||||
namespace odeint {
|
namespace odeint {
|
||||||
|
|
||||||
|
template< typename Container , typename Enabler = void >
|
||||||
|
struct is_resizeable_sfinae : boost::false_type {};
|
||||||
|
|
||||||
/*
|
template< typename Container >
|
||||||
* by default any type is not resizable
|
struct is_resizeable : is_resizeable_sfinae< Container > {};
|
||||||
*/
|
|
||||||
template< class Container , class Enabler = void >
|
|
||||||
struct is_resizeable
|
// /*
|
||||||
{
|
// * by default any type is not resizable
|
||||||
//struct type : public boost::false_type { };
|
// */
|
||||||
typedef boost::false_type type;
|
// template< class Container , class Enabler = void >
|
||||||
const static bool value = type::value;
|
// struct is_resizeable
|
||||||
};
|
// {
|
||||||
|
// //struct type : public boost::false_type { };
|
||||||
|
// typedef boost::false_type type;
|
||||||
|
// const static bool value = type::value;
|
||||||
|
// };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* specialization for std::vector
|
* specialization for std::vector
|
||||||
*/
|
*/
|
||||||
template< class V, class A >
|
template< class V, class A >
|
||||||
struct is_resizeable< std::vector< V , A > >
|
struct is_resizeable< std::vector< V , A > > : boost::true_type {};
|
||||||
{
|
// {
|
||||||
//struct type : public boost::true_type { };
|
// //struct type : public boost::true_type { };
|
||||||
typedef boost::true_type type;
|
// typedef boost::true_type type;
|
||||||
const static bool value = type::value;
|
// const static bool value = type::value;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* specialization for fusion sequences
|
* specialization for fusion sequences
|
||||||
*/
|
*/
|
||||||
template< class FusionSequence >
|
template< typename FusionSequence >
|
||||||
struct is_resizeable< FusionSequence , typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type >
|
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::find_if< FusionSequence , is_resizeable< boost::mpl::_1 > >::type iter;
|
||||||
typedef typename boost::mpl::end< FusionSequence >::type last;
|
typedef typename boost::mpl::end< FusionSequence >::type last;
|
||||||
|
@ -39,6 +39,24 @@
|
|||||||
using namespace boost::unit_test;
|
using namespace boost::unit_test;
|
||||||
using namespace boost::numeric::odeint;
|
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_AUTO_TEST_CASE( test_vector )
|
||||||
{
|
{
|
||||||
BOOST_CHECK( is_resizeable< std::vector< int > >::value );
|
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_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