Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/test/set_c.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.6 KB
Line 
1
2// Copyright Aleksey Gurtovoy 2000-2004
3//
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)
7//
8// See http://www.boost.org/libs/mpl for documentation.
9
10// $Source: /cvsroot/boost/boost/libs/mpl/test/set_c.cpp,v $
11// $Date: 2004/11/28 03:35:12 $
12// $Revision: 1.2 $
13
14#include <boost/mpl/set_c.hpp>
15#include <boost/mpl/at.hpp>
16#include <boost/mpl/size.hpp>
17
18#include <boost/mpl/aux_/test.hpp>
19
20namespace test { namespace {
21#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
22template< typename S, typename S::value_type k > 
23struct at_c
24    : at< S, integral_c<typename S::value_type,k> >::type
25{
26};
27#else
28template< typename S, long k > 
29struct at_c
30    : aux::msvc_eti_base<
31          at< S, integral_c<typename S::value_type,k> >
32        >
33{
34};
35#endif
36}}
37
38#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
39MPL_TEST_CASE()
40{
41    typedef set_c<bool,true>::type s1;
42    typedef set_c<bool,false>::type s2;
43    typedef set_c<bool,true,false>::type s3;
44
45    MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
46    MPL_ASSERT_RELATION( size<s2>::value, ==, 1 );
47    MPL_ASSERT_RELATION( size<s3>::value, ==, 2 );
48
49    MPL_ASSERT(( is_same< s1::value_type, bool > ));
50    MPL_ASSERT(( is_same< s3::value_type, bool > ));
51    MPL_ASSERT(( is_same< s2::value_type, bool > ));
52
53#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
54    MPL_ASSERT_RELATION( ( test::at_c<s1,true>::value ), ==, true );
55    MPL_ASSERT_RELATION( ( test::at_c<s2,false>::value ), ==, false );
56    MPL_ASSERT_RELATION( ( test::at_c<s3,true>::value ), ==, true );
57    MPL_ASSERT_RELATION( ( test::at_c<s3,false>::value ), ==, false );
58
59    MPL_ASSERT(( is_same< test::at_c<s1,false>::type, void_ > ));
60    MPL_ASSERT(( is_same< test::at_c<s2,true>::type, void_ > ));
61#endif
62}
63#endif
64
65MPL_TEST_CASE()
66{
67    typedef set_c<char,'a'>::type s1;
68    typedef set_c<char,'a','b','c','d','e','f','g','h'>::type s2;
69
70    MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
71    MPL_ASSERT_RELATION( size<s2>::value, ==, 8 );
72
73    MPL_ASSERT(( is_same< s1::value_type, char > ));
74    MPL_ASSERT(( is_same< s2::value_type, char > ));
75
76#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
77    MPL_ASSERT_RELATION( ( test::at_c<s1,'a'>::value ), ==, 'a' );
78    MPL_ASSERT_RELATION( ( test::at_c<s2,'a'>::value ), ==, 'a' );
79    MPL_ASSERT_RELATION( ( test::at_c<s2,'d'>::value ), ==, 'd'  );
80    MPL_ASSERT_RELATION( ( test::at_c<s2,'h'>::value ), ==, 'h' );
81
82    MPL_ASSERT(( is_same< test::at_c<s1,'z'>::type, void_ > ));
83    MPL_ASSERT(( is_same< test::at_c<s2,'k'>::type, void_ > ));
84#endif
85}
Note: See TracBrowser for help on using the repository browser.