MPL_TEST_CASE() { typedef set0<> s; MPL_ASSERT_RELATION( size<s>::value, ==, 0 ); MPL_ASSERT(( empty<s> )); MPL_ASSERT(( is_same< clear<s>::type, set0<> > )); MPL_ASSERT(( is_same< at<s,char>::type, void_ > )); MPL_ASSERT_NOT(( has_key<s,char> )); MPL_ASSERT_NOT(( has_key<s,int> )); MPL_ASSERT_NOT(( has_key<s,UDT> )); MPL_ASSERT_NOT(( has_key<s,incomplete> )); MPL_ASSERT_NOT(( has_key<s,char const> )); MPL_ASSERT_NOT(( has_key<s,int const> )); MPL_ASSERT_NOT(( has_key<s,UDT const> )); MPL_ASSERT_NOT(( has_key<s,incomplete const> )); MPL_ASSERT_NOT(( has_key<s,int*> )); MPL_ASSERT_NOT(( has_key<s,UDT*> )); MPL_ASSERT_NOT(( has_key<s,incomplete*> )); MPL_ASSERT_NOT(( has_key<s,int&> )); MPL_ASSERT_NOT(( has_key<s,UDT&> )); MPL_ASSERT_NOT(( has_key<s,incomplete&> )); typedef insert<s,char>::type s1; MPL_ASSERT_RELATION( size<s1>::value, ==, 1 ); MPL_ASSERT(( is_same< at<s1,char>::type, char > )); typedef erase_key<s,char>::type s0_1; MPL_ASSERT_RELATION( size<s0_1>::value, ==, 0 ); MPL_ASSERT(( is_same< at<s0_1,char>::type, void_ > )); }
MPL_TEST_CASE() // fully bound metafunction classes { typedef apply_wrap0< bind1<f1,int> >::type r11; typedef apply_wrap0< bind5<f5,void,void,void,void,int> >::type r51; MPL_ASSERT(( boost::is_same<r11,int> )); MPL_ASSERT(( boost::is_same<r51,int> )); }
MPL_TEST_CASE() { typedef apply1< make_identity<>, char >::type t1; typedef apply1< make_identity<_1>, int >::type t2; MPL_ASSERT(( is_same< t1, identity<char> > )); MPL_ASSERT(( is_same< t2, identity<int> > )); }
MPL_TEST_CASE() { typedef set< char,int const,long*,UDT* const,incomplete,abstract , incomplete volatile&,abstract const& > s; MPL_ASSERT_RELATION( size<s>::value, ==, 8 ); MPL_ASSERT_NOT(( empty<s> )); MPL_ASSERT(( is_same< clear<s>::type, set0<> > )); MPL_ASSERT(( is_same< at<s,bool>::type, void_ > )); MPL_ASSERT(( has_key<s,char> )); MPL_ASSERT(( has_key<s,int const> )); MPL_ASSERT(( has_key<s,long*> )); MPL_ASSERT(( has_key<s,UDT* const> )); MPL_ASSERT(( has_key<s,incomplete> )); MPL_ASSERT(( has_key<s,abstract> )); MPL_ASSERT(( has_key<s,incomplete volatile&> )); MPL_ASSERT(( has_key<s,abstract const&> )); MPL_ASSERT_NOT(( has_key<s,char const> )); MPL_ASSERT_NOT(( has_key<s,int> )); MPL_ASSERT_NOT(( has_key<s,long* const> )); MPL_ASSERT_NOT(( has_key<s,UDT*> )); MPL_ASSERT_NOT(( has_key<s,incomplete const> )); MPL_ASSERT_NOT(( has_key<s,abstract volatile> )); MPL_ASSERT_NOT(( has_key<s,incomplete&> )); MPL_ASSERT_NOT(( has_key<s,abstract&> )); }
MPL_TEST_CASE() // metafunction class composition { typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_1> >, int,void,void,void,void >::type r51; typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_5> >, void,void,void,void,int >::type r52; MPL_ASSERT(( boost::is_same<r51,int> )); MPL_ASSERT(( boost::is_same<r52,int> )); }
MPL_TEST_CASE() { MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,bool>::type, bool > )); MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,char>::type, char > )); MPL_ASSERT(( is_same< mpl::aux::largest_int<char,bool>::type, char > )); MPL_ASSERT(( is_same< mpl::aux::largest_int<int,unsigned>::type, unsigned > )); MPL_ASSERT(( is_same< mpl::aux::largest_int<unsigned,long>::type, long > )); }
MPL_TEST_CASE() { typedef always<true_> always_true; MPL_ASSERT(( apply< always_true,false_ > )); MPL_ASSERT(( apply< always_true,false_,false_ > )); MPL_ASSERT(( apply< always_true,false_,false_,false_ > )); }
MPL_TEST_CASE() { MPL_ASSERT(( is_same< mpl::min< int_<5>,int_<7> >::type,int_<5> > )); MPL_ASSERT(( is_same< mpl::max< int_<5>,int_<7> >::type,int_<7> > )); MPL_ASSERT(( is_same< mpl::min< int_<-5>,int_<-7> >::type,int_<-7> > )); MPL_ASSERT(( is_same< mpl::max< int_<-5>,int_<-7> >::type,int_<-5> > )); }
MPL_TEST_CASE() { typedef quote1<f1>::apply<int>::type t1; typedef quote5<f5>::apply<char,short,int,long,float>::type t5; MPL_ASSERT(( boost::is_same< t1, int > )); MPL_ASSERT(( boost::is_same< t5, f5<char,short,int,long,float> > )); }
MPL_TEST_CASE() { typedef mpl::advance<last,int_<-10> >::type iter1; typedef advance_c<last,-10>::type iter2; MPL_ASSERT(( is_same<iter1, first> )); MPL_ASSERT(( is_same<iter2, first> )); }
MPL_TEST_CASE() // if_ evaluation { typedef bind3< quote3<if_>, _1, bind1< quote1<next>, _2>, _3 > f; typedef apply_wrap3< f,true_,int_<0>,int >::type r1; typedef apply_wrap3< f,false_,int,int_<0> >::type r2; MPL_ASSERT(( boost::is_same<r1,int_<1> > )); MPL_ASSERT(( boost::is_same<r2,int_<0> > )); }
MPL_TEST_CASE() { typedef stable_partition< numbers , greater_equal< _, int_<3> > >::type result; MPL_ASSERT(( equal< result::first,manual_second > )); MPL_ASSERT(( equal< result::second,manual_first > )); }
MPL_TEST_CASE() { typedef list<> l0; typedef push_front<l0,char>::type l1; MPL_ASSERT(( is_same<front<l1>::type,char> )); typedef push_front<l1,long>::type l2; MPL_ASSERT(( is_same<front<l2>::type,long> )); }
MPL_TEST_CASE() { typedef list_c<bool,true>::type l1; typedef list_c<bool,false>::type l2; MPL_ASSERT(( is_same< l1::value_type, bool > )); MPL_ASSERT(( is_same< l2::value_type, bool > )); MPL_ASSERT_RELATION( front<l1>::type::value, ==, true ); MPL_ASSERT_RELATION( front<l2>::type::value, ==, false ); }
MPL_TEST_CASE() { typedef int_<0> _0; typedef int_<1> _1; typedef int_<2> _2; MPL_ASSERT(( is_same< next<_0>::type, _1 > )); MPL_ASSERT(( is_same< next<_1>::type, _2 > )); MPL_ASSERT(( is_same< prior<_1>::type, _0 > )); MPL_ASSERT(( is_same< prior<_2>::type, _1 > )); }
MPL_TEST_CASE() { typedef vector_c<bool,true>::type v1; typedef vector_c<bool,false>::type v2; MPL_ASSERT(( is_same< v1::value_type, bool > )); MPL_ASSERT(( is_same< v2::value_type, bool > )); MPL_ASSERT_RELATION( front<v1>::type::value, ==, true ); MPL_ASSERT_RELATION( front<v2>::type::value, ==, false ); }
MPL_TEST_CASE() { typedef vector2<char,long> v2; typedef begin<v2>::type i1; typedef next<i1>::type i2; typedef next<i2>::type i3; MPL_ASSERT(( is_same<deref<i1>::type,char> )); MPL_ASSERT(( is_same<deref<i2>::type,long> )); MPL_ASSERT(( is_same< i3, end<v2>::type > )); }
MPL_TEST_CASE() { typedef deque<char,long> d2; typedef begin<d2>::type i1; typedef next<i1>::type i2; typedef next<i2>::type i3; MPL_ASSERT(( is_same<deref<i1>::type,char> )); MPL_ASSERT(( is_same<deref<i2>::type,long> )); MPL_ASSERT(( is_same< i3, end<d2>::type > )); }
MPL_TEST_CASE() { typedef list<char,long> l2; typedef begin<l2>::type i1; typedef next<i1>::type i2; typedef next<i2>::type i3; MPL_ASSERT(( is_same<deref<i1>::type,char> )); MPL_ASSERT(( is_same<deref<i2>::type,long> )); MPL_ASSERT(( is_same< i3, end<l2>::type > )); }
MPL_TEST_CASE() { typedef enum_range_c<EC3,0,1> range1; typedef enum_range_c<EC3> range3; // MPL_ASSERT_RELATION( back<range1>::type::value, ==, EC3::Enum0 ); // MPL_ASSERT_RELATION( back<range3>::type::value, ==, EC3::Enum2 ); MPL_ASSERT(( is_same< enum_c<EC3,back<range1>::type::value>, enum_c<EC3,EC3::Enum0> > )); MPL_ASSERT(( is_same< enum_c<EC3,back<range3>::type::value>, enum_c<EC3,EC3::Enum2> > )); }
MPL_TEST_CASE() { typedef eval_if< true_, identity<char>, identity<long> >::type t1; typedef eval_if_c< true, identity<char>, identity<long> >::type t2; typedef eval_if< false_, identity<char>, identity<long> >::type t3; typedef eval_if_c< false, identity<char>, identity<long> >::type t4; MPL_ASSERT(( is_same<t1,char> )); MPL_ASSERT(( is_same<t2,char> )); MPL_ASSERT(( is_same<t3,long> )); MPL_ASSERT(( is_same<t4,long> )); }
MPL_TEST_CASE() { typedef begin<empty_sequence>::type begin; typedef end<empty_sequence>::type end; MPL_ASSERT(( is_same<begin,end> )); MPL_ASSERT_RELATION( (mpl::distance<begin,end>::value), ==, 0 ); MPL_ASSERT_RELATION( size<empty_sequence>::value, ==, 0 ); typedef advance_c<begin,0>::type advanced; MPL_ASSERT(( is_same<advanced,end> )); }
MPL_TEST_CASE() // basic argument binding { typedef apply_wrap1< bind1<f1,_1>, int >::type r11; typedef apply_wrap5< bind1<f1,_5>, void,void,void,void,int >::type r12; MPL_ASSERT(( boost::is_same<r11,int> )); MPL_ASSERT(( boost::is_same<r12,int> )); typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,_5>, void,void,void,void,int >::type r51; typedef apply_wrap5< bind5<f5,_5,_4,_3,_2,_1>, int,void,void,void,void >::type r52; MPL_ASSERT(( boost::is_same<r51,int> )); MPL_ASSERT(( boost::is_same<r52,int> )); }
MPL_TEST_CASE() { typedef list_c<unsigned,0>::type l1; typedef list_c<unsigned,1,2>::type l2; MPL_ASSERT(( is_same< l1::value_type, unsigned > )); MPL_ASSERT(( is_same< l2::value_type, unsigned > )); MPL_ASSERT_RELATION( size<l1>::value, ==, 1 ); MPL_ASSERT_RELATION( size<l2>::value, ==, 2 ); MPL_ASSERT_RELATION( front<l1>::type::value, ==, 0 ); MPL_ASSERT_RELATION( front<l2>::type::value, ==, 1 ); }
MPL_TEST_CASE() { typedef deque<> d0; typedef push_back<d0,int>::type d1; MPL_ASSERT(( is_same< back<d1>::type,int > )); typedef push_front<d1,char>::type d2; MPL_ASSERT(( is_same< back<d2>::type,int > )); MPL_ASSERT(( is_same< front<d2>::type,char > )); typedef push_back<d2,long>::type d3; MPL_ASSERT(( is_same< back<d3>::type,long > )); }
MPL_TEST_CASE() { MPL_ASSERT_NOT(( is_sequence< std_vector<int> > )); MPL_ASSERT_NOT(( is_sequence< int_<0> > )); MPL_ASSERT_NOT(( is_sequence< int > )); MPL_ASSERT_NOT(( is_sequence< int& > )); MPL_ASSERT_NOT(( is_sequence< UDT > )); MPL_ASSERT_NOT(( is_sequence< UDT* > )); MPL_ASSERT(( is_sequence< range_c<int,0,0> > )); MPL_ASSERT(( is_sequence< list<> > )); MPL_ASSERT(( is_sequence< list<int> > )); MPL_ASSERT(( is_sequence< vector<> > )); MPL_ASSERT(( is_sequence< vector<int> > )); }
MPL_TEST_CASE() { typedef enum_range_c<EC3> r; typedef begin<r>::type first; typedef end<r>::type last; MPL_ASSERT(( is_same< advance_c<first,3>::type, last > )); MPL_ASSERT(( is_same< advance_c<last,-3>::type, first > )); MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 3 ); // typedef advance_c<first,5>::type iter; // MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 ); }
MPL_TEST_CASE() { typedef vector_c<unsigned,0> v1; typedef vector_c<unsigned,1,2> v2; MPL_ASSERT(( is_same< v1::value_type, unsigned > )); MPL_ASSERT(( is_same< v2::value_type, unsigned > )); MPL_ASSERT_RELATION( size<v1>::type::value, ==, 1 ); MPL_ASSERT_RELATION( size<v2>::type::value, ==, 2 ); MPL_ASSERT_RELATION( front<v1>::type::value, ==, 0 ); MPL_ASSERT_RELATION( front<v2>::type::value, ==, 1 ); }
MPL_TEST_CASE() { typedef list_c<unsigned,2,1> l2; MPL_ASSERT(( is_same< l2::value_type, unsigned > )); typedef begin<l2>::type i1; typedef next<i1>::type i2; typedef next<i2>::type i3; MPL_ASSERT_RELATION( deref<i1>::type::value, ==, 2 ); MPL_ASSERT_RELATION( deref<i2>::type::value, ==, 1 ); MPL_ASSERT(( is_same< i3, end<l2>::type > )); }
MPL_TEST_CASE() { typedef range_c<unsigned char,0,10> r; typedef begin<r>::type first; typedef end<r>::type last; MPL_ASSERT(( is_same< advance_c<first,10>::type, last > )); MPL_ASSERT(( is_same< advance_c<last,-10>::type, first > )); MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 10 ); typedef advance_c<first,5>::type iter; MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 ); }