2 // Copyright Aleksey Gurtovoy 2000-2004
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org/libs/mpl for documentation.
14 #include <boost/mpl/set_c.hpp>
15 #include <boost/mpl/at.hpp>
16 #include <boost/mpl/size.hpp>
17 #include <boost/mpl/begin_end.hpp>
19 #include <boost/mpl/aux_/test.hpp>
21 namespace test { namespace {
22 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
23 template< typename S, typename S::value_type k >
25 : at< S, integral_c<typename S::value_type,k> >::type
29 template< typename S, long k >
32 at< S, integral_c<typename S::value_type,k> >
39 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
42 typedef set_c<bool,true>::type s1;
43 typedef set_c<bool,false>::type s2;
44 typedef set_c<bool,true,false>::type s3;
46 MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
47 MPL_ASSERT_RELATION( size<s2>::value, ==, 1 );
48 MPL_ASSERT_RELATION( size<s3>::value, ==, 2 );
50 MPL_ASSERT(( is_same< s1::value_type, bool > ));
51 MPL_ASSERT(( is_same< s3::value_type, bool > ));
52 MPL_ASSERT(( is_same< s2::value_type, bool > ));
54 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
55 MPL_ASSERT_RELATION( ( test::at_c<s1,true>::value ), ==, true );
56 MPL_ASSERT_RELATION( ( test::at_c<s2,false>::value ), ==, false );
57 MPL_ASSERT_RELATION( ( test::at_c<s3,true>::value ), ==, true );
58 MPL_ASSERT_RELATION( ( test::at_c<s3,false>::value ), ==, false );
60 MPL_ASSERT(( is_same< test::at_c<s1,false>::type, void_ > ));
61 MPL_ASSERT(( is_same< test::at_c<s2,true>::type, void_ > ));
64 typedef begin<s1>::type first1;
65 typedef end<s1>::type last1;
66 MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 );
68 typedef begin<s2>::type first2;
69 typedef end<s2>::type last2;
70 MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 1 );
72 typedef begin<s3>::type first3;
73 typedef end<s3>::type last3;
74 MPL_ASSERT_RELATION( (distance<first3, last3>::value), ==, 2 );
80 typedef set_c<char,'a'>::type s1;
81 typedef set_c<char,'a','b','c','d','e','f','g','h'>::type s2;
83 MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
84 MPL_ASSERT_RELATION( size<s2>::value, ==, 8 );
86 MPL_ASSERT(( is_same< s1::value_type, char > ));
87 MPL_ASSERT(( is_same< s2::value_type, char > ));
89 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
90 MPL_ASSERT_RELATION( ( test::at_c<s1,'a'>::value ), ==, 'a' );
91 MPL_ASSERT_RELATION( ( test::at_c<s2,'a'>::value ), ==, 'a' );
92 MPL_ASSERT_RELATION( ( test::at_c<s2,'d'>::value ), ==, 'd' );
93 MPL_ASSERT_RELATION( ( test::at_c<s2,'h'>::value ), ==, 'h' );
95 MPL_ASSERT(( is_same< test::at_c<s1,'z'>::type, void_ > ));
96 MPL_ASSERT(( is_same< test::at_c<s2,'k'>::type, void_ > ));
99 typedef begin<s1>::type first1;
100 typedef end<s1>::type last1;
101 MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 );
103 typedef begin<s2>::type first2;
104 typedef end<s2>::type last2;
105 MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 8 );