forked from boostorg/mpl
merge new MPL version from 'mplbook' branch
[SVN r24874]
This commit is contained in:
+49
-40
@@ -1,60 +1,69 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost mpl/test/list_c.cpp source file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Copyright (c) 2000-02
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org/libs/mpl for documentation.
|
||||
|
||||
#include "boost/mpl/list_c.hpp"
|
||||
#include "boost/mpl/front.hpp"
|
||||
#include "boost/mpl/size.hpp"
|
||||
#include "boost/static_assert.hpp"
|
||||
#include "boost/config.hpp"
|
||||
// $Source$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
#include <boost/mpl/list_c.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
|
||||
void test_bool_list()
|
||||
#include <boost/mpl/aux_/test.hpp>
|
||||
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC,<= 1200)
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef mpl::list_c<bool,true>::type list1;
|
||||
typedef mpl::list_c<bool,false>::type list2;
|
||||
typedef list_c<bool,true>::type list1;
|
||||
typedef list_c<bool,false>::type list2;
|
||||
|
||||
BOOST_STATIC_ASSERT(mpl::front<list1>::type::value == true);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list2>::type::value == false);
|
||||
MPL_ASSERT_RELATION( front<list1>::type::value, ==, true );
|
||||
MPL_ASSERT_RELATION( front<list2>::type::value, ==, false );
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_int_list()
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef mpl::list_c<int,-1>::type list1;
|
||||
typedef mpl::list_c<int,0,1>::type list2;
|
||||
typedef mpl::list_c<int,1,2,3>::type list3;
|
||||
typedef list_c<int,-1>::type list1;
|
||||
typedef list_c<int,0,1>::type list2;
|
||||
typedef list_c<int,1,2,3>::type list3;
|
||||
|
||||
BOOST_STATIC_ASSERT(mpl::size<list1>::type::value == 1);
|
||||
BOOST_STATIC_ASSERT(mpl::size<list2>::type::value == 2);
|
||||
BOOST_STATIC_ASSERT(mpl::size<list3>::type::value == 3);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list1>::type::value == -1);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list2>::type::value == 0);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list3>::type::value == 1);
|
||||
MPL_ASSERT_RELATION( size<list1>::value, ==, 1 );
|
||||
MPL_ASSERT_RELATION( size<list2>::value, ==, 2 );
|
||||
MPL_ASSERT_RELATION( size<list3>::value, ==, 3 );
|
||||
MPL_ASSERT_RELATION( front<list1>::type::value, ==, -1 );
|
||||
MPL_ASSERT_RELATION( front<list2>::type::value, ==, 0 );
|
||||
MPL_ASSERT_RELATION( front<list3>::type::value, ==, 1 );
|
||||
}
|
||||
|
||||
void test_unsigned_list()
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
typedef mpl::list_c<unsigned,0>::type list1;
|
||||
typedef mpl::list_c<unsigned,1,2>::type list2;
|
||||
typedef list_c<unsigned,0>::type list1;
|
||||
typedef list_c<unsigned,1,2>::type list2;
|
||||
|
||||
BOOST_STATIC_ASSERT(mpl::size<list1>::type::value == 1);
|
||||
BOOST_STATIC_ASSERT(mpl::size<list2>::type::value == 2);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list1>::type::value == 0);
|
||||
BOOST_STATIC_ASSERT(mpl::front<list2>::type::value == 1);
|
||||
MPL_ASSERT_RELATION( size<list1>::value, ==, 1 );
|
||||
MPL_ASSERT_RELATION( size<list2>::value, ==, 2 );
|
||||
MPL_ASSERT_RELATION( front<list1>::type::value, ==, 0 );
|
||||
MPL_ASSERT_RELATION( front<list2>::type::value, ==, 1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
MPL_TEST_CASE()
|
||||
{
|
||||
return 0;
|
||||
typedef list_c<unsigned,2,1> l2;
|
||||
|
||||
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 > ));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user