merge new MPL version from 'mplbook' branch

[SVN r24874]
This commit is contained in:
Aleksey Gurtovoy committed 2004-09-02 15:41:37 +00:00
1 parent e2e70427cc
commit 1689c8ef83
1216 files changed
+89913 -36752

No files matched your search

+14 -6
View File
@@ -11,23 +11,22 @@ compile apply.cpp ;
compile apply_if.cpp ;
compile arithmetic.cpp ;
compile as_sequence.cpp ;
compile assert_is_same.cpp ;
compile assert.cpp ;
compile at.cpp ;
compile back.cpp ;
compile bind.cpp ;
compile bitwise.cpp ;
compile bool.cpp ;
run bool.cpp ;
compile comparison.cpp ;
compile contains.cpp ;
compile copy.cpp ;
compile copy_backward.cpp ;
compile copy_backward_if.cpp ;
compile copy_if.cpp ;
compile count.cpp ;
compile count_if.cpp ;
compile distance.cpp ;
compile empty.cpp ;
compile equal.cpp ;
compile equal_to.cpp ;
compile erase.cpp ;
compile erase_range.cpp ;
compile filter_view.cpp ;
@@ -36,6 +35,7 @@ compile find_if.cpp ;
compile fold.cpp ;
unit-test for_each : for_each.cpp : <sysinclude>$(BOOST_ROOT) ;
compile front.cpp ;
compile has_xxx.cpp ;
compile identity.cpp ;
compile if.cpp ;
compile index_of.cpp ;
@@ -46,16 +46,22 @@ compile int.cpp ;
compile integral_c.cpp ;
compile is_placeholder.cpp ;
compile is_sequence.cpp ;
compile iterator_tag.cpp ;
compile joint_view.cpp ;
compile lambda.cpp ;
compile lambda_apply_bind.cpp ;
compile lambda_args.cpp ;
compile max_element.cpp ;
compile multiset.cpp ;
compile list.cpp ;
compile list_c.cpp ;
compile logical.cpp ;
compile lower_bound.cpp ;
compile map.cpp ;
compile max_element.cpp ;
compile min_max.cpp ;
compile multiset.cpp ;
compile next.cpp ;
compile no_has_xxx.cpp ;
compile pair_view.cpp ;
compile pop_front.cpp ;
compile push_front.cpp ;
compile quote.cpp ;
@@ -64,6 +70,7 @@ compile replace.cpp ;
compile replace_if.cpp ;
compile reverse.cpp ;
compile same_as.cpp ;
compile set.cpp ;
compile single_view.cpp ;
compile size.cpp ;
compile sizeof.cpp ;
@@ -72,6 +79,7 @@ compile stable_partition.cpp ;
compile transform.cpp ;
compile transform_view.cpp ;
compile unique.cpp ;
compile unpack_args.cpp ;
compile upper_bound.cpp ;
compile vector.cpp ;
compile vector_c.cpp ;
+42 -24
View File
@@ -1,33 +1,51 @@
//-----------------------------------------------------------------------------
// boost mpl/test/advance.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/vector/vector10_c.hpp"
#include "boost/mpl/advance.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/assert_is_same.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/advance.hpp>
#include <boost/mpl/iterator_tags.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
template< int pos > struct iter
{
typedef mpl::vector10_c<int,0,1,2,3,4,5,6,7,8,9> numbers;
typedef mpl::begin<numbers>::type first;
typedef mpl::end<numbers>::type last;
typedef mpl::bidirectional_iterator_tag category;
typedef iter<(pos + 1)> next;
typedef iter<(pos - 1)> prior;
typedef int_<pos> type;
};
typedef mpl::advance_c<first,10>::type iter1;
typedef mpl::advance_c<last,-10>::type iter2;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
namespace boost { namespace mpl {
template< int pos, typename Default > struct tag< iter<pos>,Default > : void_ {};
}}
#endif
BOOST_MPL_ASSERT_IS_SAME(iter1, last);
BOOST_MPL_ASSERT_IS_SAME(iter2, first);
return 0;
typedef iter<0> first;
typedef iter<10> last;
MPL_TEST_CASE()
{
typedef mpl::advance<first,int_<10> >::type iter1;
typedef advance_c<first,10>::type iter2;
MPL_ASSERT(( is_same<iter1, last> ));
MPL_ASSERT(( is_same<iter2, last> ));
}
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> ));
}
+34 -34
View File
@@ -1,42 +1,42 @@
//-----------------------------------------------------------------------------
// boost mpl/test/always.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/always.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/apply.hpp>
#include <boost/mpl/always.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/int.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::always<mpl::true_> always_true;
typedef mpl::apply1< always_true,mpl::false_ >::type res1;
typedef mpl::apply2< always_true,mpl::false_,mpl::false_ >::type res2;
typedef mpl::apply3< always_true,mpl::false_,mpl::false_,mpl::false_ >::type res3;
typedef always<true_> always_true;
BOOST_STATIC_ASSERT(res1::value == true);
BOOST_STATIC_ASSERT(res2::value == true);
BOOST_STATIC_ASSERT(res3::value == true);
typedef mpl::always< mpl::int_<10> > always_10;
typedef mpl::apply1< always_10,mpl::int_<0> >::type res4;
typedef mpl::apply2< always_10,mpl::int_<0>,mpl::int_<0> >::type res5;
typedef mpl::apply3< always_10,mpl::int_<0>,mpl::int_<0>,mpl::int_<0> >::type res6;
BOOST_STATIC_ASSERT(res4::value == 10);
BOOST_STATIC_ASSERT(res5::value == 10);
BOOST_STATIC_ASSERT(res6::value == 10);
return 0;
MPL_ASSERT(( apply1< always_true,false_ > ));
MPL_ASSERT(( apply2< always_true,false_,false_ > ));
MPL_ASSERT(( apply3< always_true,false_,false_,false_ > ));
}
MPL_TEST_CASE()
{
typedef always< int_<10> > always_10;
typedef apply1< always_10,int_<0> >::type res1;
typedef apply2< always_10,int_<0>,int_<0> >::type res2;
typedef apply3< always_10,int_<0>,int_<0>,int_<0> >::type res3;
MPL_ASSERT_RELATION( res1::value, ==, 10 );
MPL_ASSERT_RELATION( res2::value, ==, 10 );
MPL_ASSERT_RELATION( res3::value, ==, 10 );
}
+119 -101
View File
@@ -1,110 +1,128 @@
//-----------------------------------------------------------------------------
// boost mpl/test/apply.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/apply.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/mpl/limits/arity.hpp"
#include "boost/mpl/aux_/preprocessor/params.hpp"
#include "boost/mpl/aux_/preprocessor/enum.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/preprocessor/repeat.hpp"
#include "boost/preprocessor/comma_if.hpp"
#include "boost/preprocessor/dec.hpp"
#include "boost/preprocessor/if.hpp"
#include "boost/preprocessor/cat.hpp"
#include <boost/mpl/apply.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
namespace mpl = boost::mpl;
#define APPLY_0_FUNC_DEF(i) \
struct f0 { typedef char type; }; \
/**/
#define APPLY_N_FUNC_DEF(i) \
struct first##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef U1 type; }; \
}; \
\
struct last##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef BOOST_PP_CAT(U,i) type; }; \
}; \
/**/
#define APPLY_FUNC_DEF(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_FUNC_DEF \
, APPLY_0_FUNC_DEF \
)(i) \
/**/
namespace aux {
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_FUNC_DEF
, unused
)
}
#define APPLY_0_TEST(i, apply_) \
typedef mpl::apply_<aux::f##i>::type t; \
{ BOOST_MPL_ASSERT_IS_SAME(t, char); } \
/**/
#define APPLY_N_TEST(i, apply_) \
typedef mpl::apply_< \
aux::first##i \
, char \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
>::type t1; \
\
typedef mpl::apply_< \
aux::last##i \
, BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
>::type t2; \
{ BOOST_MPL_ASSERT_IS_SAME(t1, char); } \
{ BOOST_MPL_ASSERT_IS_SAME(t2, char); } \
/**/
#define APPLY_TEST(z, i, APPLY_NAME) \
BOOST_PP_IF( \
i \
, APPLY_N_TEST \
, APPLY_0_TEST \
)(i, APPLY_NAME(i)) \
/**/
#define MAKE_APPLY_N_NAME(i) apply##i
#define MAKE_APPLY_NAME(i) apply
int main()
template< typename T > struct std_vector
{
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_N_NAME
)
#if defined(BOOST_MPL_HAS_APPLY)
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_NAME
)
#if defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS)
typedef std_vector type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(1, std_vector, (T))
#endif
return 0;
};
MPL_TEST_CASE()
{
typedef plus<int_<2>,int_<3> > plus1;
typedef lambda<plus1>::type plus2;
MPL_ASSERT(( is_same< plus1,plus2 > ));
typedef lambda<std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef lambda<std_vector<_1> >::type make_vector;
typedef apply_wrap1<make_vector,int>::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef plus<_1,_2> plus_fun;
typedef apply2<plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef apply1<_1, plus<_1,_2> >::type plus_fun;
MPL_ASSERT(( is_same< plus_fun,plus<_1,_2> > ));
typedef apply2<plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef lambda< lambda<_1> >::type make_lambda;
typedef apply_wrap1< make_lambda,std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply_wrap1< make_lambda,std_vector<_1> >::type make_vector;
typedef apply_wrap1< make_vector,int >::type v_int;
MPL_ASSERT(( is_same< v_int,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< _1, std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply1< _1, std_vector<_1> >::type v_lambda;
typedef apply1<v_lambda,int>::type v_int;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< lambda<_1>, std_vector<int> >::type v;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
typedef apply1< lambda<_1>, std_vector<_1> >::type make_vector;
typedef apply_wrap1< make_vector,int >::type v_int;
MPL_ASSERT(( is_same< v,std_vector<int> > ));
}
MPL_TEST_CASE()
{
typedef apply1< lambda<_1>, plus<_1,_2> >::type plus_fun;
typedef apply_wrap2< plus_fun,int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
MPL_TEST_CASE()
{
typedef bind2<plus<>,_1,_1> b1;
typedef lambda<b1>::type b2;
MPL_ASSERT(( is_same< b1,b2 > ));
}
MPL_TEST_CASE()
{
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
typedef lambda< lambda< bind2<plus<>,_1,_1> > >::type make_lambda;
typedef apply_wrap1< make_lambda::type, int_<5> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 10 );
#endif
}
MPL_TEST_CASE()
{
typedef apply1< bind2<plus<>,_1,_1>, int_<5> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 10 );
}
MPL_TEST_CASE()
{
typedef apply1<_1, lambda<plus<_1,_2> > >::type plus_fun;
typedef apply_wrap2< plus_fun::type, int_<2>,int_<3> >::type res;
MPL_ASSERT_RELATION( res::value, ==, 5 );
}
-53
View File
@@ -1,53 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/apply_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/apply_if.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::apply_if<
mpl::true_
, mpl::identity<char>
, mpl::identity<long>
>::type t1;
typedef mpl::apply_if_c<
true
, mpl::identity<char>
, mpl::identity<long>
>::type t2;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
BOOST_MPL_ASSERT_IS_SAME(t2, char);
typedef mpl::apply_if<
mpl::false_
, mpl::identity<char>
, mpl::identity<long>
>::type t3;
typedef mpl::apply_if_c<
false
, mpl::identity<char>
, mpl::identity<long>
>::type t4;
BOOST_MPL_ASSERT_IS_SAME(t3, long);
BOOST_MPL_ASSERT_IS_SAME(t4, long);
return 0;
}
+110
View File
@@ -0,0 +1,110 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/limits/arity.hpp>
#include <boost/mpl/aux_/preprocessor/params.hpp>
#include <boost/mpl/aux_/preprocessor/enum.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/dec.hpp>
#include <boost/preprocessor/if.hpp>
#include <boost/preprocessor/cat.hpp>
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T = int > struct apply { typedef char type; }; \
}; \
/**/
#else
# define APPLY_0_FUNC_DEF(i) \
struct f0 \
{ \
template< typename T > struct apply { typedef char type; }; \
}; \
/**/
#endif
#define APPLY_N_FUNC_DEF(i) \
struct first##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef U1 type; }; \
}; \
\
struct last##i \
{ \
template< BOOST_MPL_PP_PARAMS(i, typename U) > \
struct apply { typedef BOOST_PP_CAT(U,i) type; }; \
}; \
/**/
#define APPLY_FUNC_DEF(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_FUNC_DEF \
, APPLY_0_FUNC_DEF \
)(i) \
/**/
namespace { namespace test {
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_FUNC_DEF
, unused
)
}}
#define APPLY_0_TEST(i, apply_) \
typedef apply_<test::f##i>::type t; \
{ MPL_ASSERT(( boost::is_same<t, char> )); } \
/**/
#define APPLY_N_TEST(i, apply_) \
typedef apply_< \
test::first##i \
, char \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \
BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
>::type t1##i; \
\
typedef apply_< \
test::last##i \
, BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \
>::type t2##i; \
{ MPL_ASSERT(( boost::is_same<t1##i, char> )); } \
{ MPL_ASSERT(( boost::is_same<t2##i, char> )); } \
/**/
#define APPLY_TEST(z, i, unused) \
BOOST_PP_IF( \
i \
, APPLY_N_TEST \
, APPLY_0_TEST \
)(i, BOOST_PP_CAT(apply_wrap,i)) \
/**/
MPL_TEST_CASE()
{
BOOST_PP_REPEAT(
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, APPLY_TEST
, unused
)
}
+36 -35
View File
@@ -1,49 +1,50 @@
//-----------------------------------------------------------------------------
// boost mpl/test/arithmetic.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/arithmetic.hpp"
#include "boost/mpl/int.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::int_<0> _0;
typedef mpl::int_<1> _1;
typedef mpl::int_<3> _3;
typedef mpl::int_<10> _10;
typedef int_<0> _0;
typedef int_<1> _1;
typedef int_<3> _3;
typedef int_<10> _10;
BOOST_STATIC_ASSERT((mpl::plus<_0,_10>::value == 10));
BOOST_STATIC_ASSERT((mpl::plus<_10,_0>::value == 10));
MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 );
BOOST_STATIC_ASSERT((mpl::minus<_0,_10>::value == -10));
BOOST_STATIC_ASSERT((mpl::minus<_10,_0>::value == 10));
MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 );
MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 );
BOOST_STATIC_ASSERT((mpl::multiplies<_1,_10>::value == 10));
BOOST_STATIC_ASSERT((mpl::multiplies<_10,_1>::value == 10));
MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 );
MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 );
BOOST_STATIC_ASSERT((mpl::divides<_10,_1>::value == 10));
BOOST_STATIC_ASSERT((mpl::divides<_10,_1>::value == 10));
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 );
BOOST_STATIC_ASSERT((mpl::modulus<_10,_1>::value == 0));
BOOST_STATIC_ASSERT((mpl::modulus<_10,_3>::value == 1));
MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 );
BOOST_STATIC_ASSERT((mpl::minus<_10,_1,_10>::value == -1));
BOOST_STATIC_ASSERT((mpl::plus<_10,_1,_10>::value == 21));
BOOST_STATIC_ASSERT((mpl::divides<_10,_1,_10>::value == 1));
BOOST_STATIC_ASSERT((mpl::divides<_10,_1,_10>::value == 1));
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 );
MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 );
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 );
#endif
BOOST_STATIC_ASSERT((mpl::negate<_10>::value == -10));
return 0;
MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 );
}
+16 -21
View File
@@ -1,28 +1,23 @@
//-----------------------------------------------------------------------------
// boost mpl/test/as_sequence.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2002-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/vector.hpp"
#include "boost/mpl/as_sequence.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost::mpl;
#include <boost/mpl/as_sequence.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/test.hpp>
struct UDT {};
int main()
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT(is_sequence< as_sequence<int>::type >::value);
BOOST_STATIC_ASSERT(is_sequence< as_sequence<UDT>::type >::value);
BOOST_STATIC_ASSERT(is_sequence< as_sequence< vector<> >::type >::value);
return 0;
MPL_ASSERT(( is_sequence< as_sequence<int>::type > ));
MPL_ASSERT(( is_sequence< as_sequence<UDT>::type > ));
MPL_ASSERT(( is_sequence< as_sequence< vector<> >::type > ));
}
+88
View File
@@ -0,0 +1,88 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_pointer.hpp>
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () );
namespace my {
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () );
}
template< typename T >
struct her
{
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () );
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) );
#endif
void f()
{
BOOST_MPL_ASSERT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () );
#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) );
#endif
}
};
int main()
{
her<void> h;
h.f();
BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () );
BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () );
return 0;
}
-28
View File
@@ -1,28 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/assert_is_same.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/assert_is_same.hpp"
namespace {
struct my;
}
int main()
{
BOOST_MPL_ASSERT_IS_SAME(long, long);
BOOST_MPL_ASSERT_IS_SAME(my, my);
BOOST_MPL_ASSERT_NOT_SAME(my, long);
BOOST_MPL_ASSERT_NOT_SAME(long, my);
return 0;
}
+31 -27
View File
@@ -1,35 +1,39 @@
//-----------------------------------------------------------------------------
// boost mpl/test/at.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/at.hpp"
#include "boost/mpl/vector/vector10_c.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/at.hpp>
#include <boost/mpl/vector/vector10_c.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
template< typename Seq, int n > struct at_test
{
typedef mpl::vector10_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
typedef typename at_c<Seq,n>::type t;
MPL_ASSERT(( is_same< t, integral_c<int,9-n> > ));
MPL_ASSERT_RELATION( t::value, ==, 9 - n );
};
BOOST_STATIC_ASSERT((mpl::at_c<numbers,0>::type::value == 9));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,1>::type::value == 8));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,2>::type::value == 7));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,3>::type::value == 6));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,4>::type::value == 5));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,5>::type::value == 4));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,6>::type::value == 3));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,7>::type::value == 2));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,8>::type::value == 1));
BOOST_STATIC_ASSERT((mpl::at_c<numbers,9>::type::value == 0));
return 0;
MPL_TEST_CASE()
{
typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
at_test< numbers, 0 >();
at_test< numbers, 1 >();
at_test< numbers, 2 >();
at_test< numbers, 3 >();
at_test< numbers, 4 >();
at_test< numbers, 5 >();
at_test< numbers, 6 >();
at_test< numbers, 7 >();
at_test< numbers, 8 >();
at_test< numbers, 9 >();
}
+4 -6
View File
@@ -3,10 +3,8 @@ subproject libs/mpl/test/aux_ ;
# bring in rules for testing
import testing ;
compile debug_print.cpp ;
compile has_rebind.cpp ;
compile has_distance.cpp ;
compile has_xxx.cpp ;
compile no_has_xxx.cpp ;
compile typeof.cpp ;
compile preprocessor/is_seq.cpp ;
compile preprocessor/token_equal.cpp ;
compile largest_int.cpp ;
compile msvc_is_class.cpp ;
compile template_arity.cpp ;
-19
View File
@@ -1,19 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/typeof.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002
// Aleksey Gurtovoy
//
// 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)
#include "boost/mpl/aux_/debug_print.hpp"
int main()
{
BOOST_MPL_AUX_DEBUG_PRINT(int);
return 0;
}
-34
View File
@@ -1,34 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/aux_/has_distance.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/aux_/has_distance.hpp"
#include "boost/mpl/aux_/has_distance_spec.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
struct iter0 {};
template< typename T > struct iter1
{
template< typename > struct BOOST_MPL_AUX_ITERATOR_DISTANCE;
};
namespace boost { namespace mpl {
BOOST_MPL_AUX_HAS_DISTANCE_SPEC(1,iter1)
}}
int main()
{
BOOST_STATIC_ASSERT(!mpl::aux::has_distance<iter0>::value);
BOOST_STATIC_ASSERT(mpl::aux::has_distance< iter1<int> >::value);
return 0;
}
-26
View File
@@ -1,26 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/aux_/has_rebind.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/aux_/has_rebind.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
struct f1 {};
struct f2 { struct rebind; };
int main()
{
BOOST_STATIC_ASSERT(!mpl::aux::has_rebind<f1>::value);
BOOST_STATIC_ASSERT(mpl::aux::has_rebind<f2>::value);
return 0;
}
-63
View File
@@ -1,63 +0,0 @@
// + file: libs/mpl/test/aux_/has_xxx.cpp
// + last modified: 09/jun/03
// Copyright (c) 2000-03
// Aleksey Gurtovoy
//
// 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/aux_/has_xxx.hpp"
#include "boost/mpl/aux_/config/workaround.hpp"
#include "boost/static_assert.hpp"
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
struct a1;
struct a2 {};
struct a3 { void xxx(); };
struct a4 { int xxx; };
struct a5 { static int xxx(); };
struct b1 { typedef int xxx; };
struct b2 { struct xxx; };
struct b3 { typedef int& xxx; };
struct b4 { typedef int* xxx; };
struct b5 { typedef int xxx[10]; };
struct b6 { typedef void (*xxx)(); };
struct b7 { typedef void (xxx)(); };
template <class T> struct outer;
template <class T> struct inner { typedef typename T::type type; };
int main()
{
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
BOOST_STATIC_ASSERT(!has_xxx<int&>::value);
BOOST_STATIC_ASSERT(!has_xxx<int*>::value);
BOOST_STATIC_ASSERT(!has_xxx<int[]>::value);
BOOST_STATIC_ASSERT(!has_xxx<int (*)()>::value);
#endif
BOOST_STATIC_ASSERT(!has_xxx<int>::value);
BOOST_STATIC_ASSERT(!has_xxx<a1>::value);
BOOST_STATIC_ASSERT(!has_xxx<a2>::value);
BOOST_STATIC_ASSERT(!has_xxx<a3>::value);
BOOST_STATIC_ASSERT(!has_xxx<a4>::value);
BOOST_STATIC_ASSERT(!has_xxx<a5>::value);
BOOST_STATIC_ASSERT(has_xxx<b1>::value);
BOOST_STATIC_ASSERT(has_xxx<b2>::value);
BOOST_STATIC_ASSERT(has_xxx<b3>::value);
BOOST_STATIC_ASSERT(has_xxx<b4>::value);
BOOST_STATIC_ASSERT(has_xxx<b5>::value);
BOOST_STATIC_ASSERT(has_xxx<b6>::value);
BOOST_STATIC_ASSERT(has_xxx<b7>::value);
BOOST_STATIC_ASSERT(!has_xxx<outer<inner<int> > >::value);
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/aux_/largest_int.hpp>
#include <boost/mpl/aux_/test.hpp>
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 > ));
}
+46
View File
@@ -0,0 +1,46 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/aux_/config/msvc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
#include <boost/mpl/aux_/msvc_is_class.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct A { T x[0]; };
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( aux::msvc_is_class< int > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< char > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< enum_ > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< char* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< UDT* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< UDT& > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete* > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete& > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< int[5] > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< void (*)() > ));
MPL_ASSERT_NOT(( aux::msvc_is_class< int (*)(int, char) > ));
MPL_ASSERT(( aux::msvc_is_class< UDT > ));
MPL_ASSERT(( aux::msvc_is_class< incomplete > ));
MPL_ASSERT(( aux::msvc_is_class< abstract > ));
MPL_ASSERT(( aux::msvc_is_class< noncopyable > ));
MPL_ASSERT(( aux::msvc_is_class< A<int> > ));
MPL_ASSERT(( aux::msvc_is_class< A<incomplete> > ));
}
#endif
-66
View File
@@ -1,66 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/aux_/no_has_xxx.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-03
// Aleksey Gurtovoy, Dave Abrahams
//
// 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)
#include "boost/mpl/aux_/has_xxx.hpp"
#include "boost/mpl/aux_/config/workaround.hpp"
#include "boost/static_assert.hpp"
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx_type)
struct a1;
struct a2 {};
struct a3 { typedef int xxx_type; };
struct a4 { struct xxx_type; };
struct a5 { typedef int& xxx_type; };
struct a6 { typedef int* xxx_type; };
struct a7 { typedef int xxx_type[10]; };
struct a8 { typedef void (*xxx_type)(); };
struct a9 { typedef void (xxx_type)(); };
//
// This file tests that we have the right value for
// BOOST_MPL_NO_AUX_HAS_XXX, and that has_xxx doesn't just fail to
// compile arbitrarily. Could be used as part of the config tests.
//
#undef FALSE
#undef TRUE
#define FALSE false
#ifdef BOOST_MPL_NO_AUX_HAS_XXX
# define TRUE FALSE
#else
# define TRUE true
#endif
int main()
{
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
BOOST_STATIC_ASSERT(has_xxx_type<int&>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<int*>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<int[]>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<int (*)()>::value == FALSE);
#endif
BOOST_STATIC_ASSERT(has_xxx_type<int>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<a1>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<a2>::value == FALSE);
BOOST_STATIC_ASSERT(has_xxx_type<a3>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a4>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a5>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a6>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a7>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a8>::value == TRUE);
BOOST_STATIC_ASSERT(has_xxx_type<a9>::value == TRUE);
return 0;
}
+15 -20
View File
@@ -1,20 +1,20 @@
// + file: libs/mpl/test/aux_/is_seq.cpp
// + last modified: 03/may/03
// Copyright (c) 2003
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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/aux_/preprocessor/is_seq.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/preprocessor/logical/not.hpp"
#include "boost/preprocessor/debug/assert.hpp"
#include <boost/mpl/aux_/preprocessor/is_seq.hpp>
#include <boost/preprocessor/logical/not.hpp>
#include <boost/preprocessor/debug/assert.hpp>
#define AUX_ASSERT_IS_SEQ( seq ) \
BOOST_PP_ASSERT( BOOST_MPL_PP_IS_SEQ(seq) ) \
@@ -26,13 +26,8 @@
#define SEQ (a)(b)(c)
int main()
{
AUX_ASSERT_IS_NOT_SEQ( a )
AUX_ASSERT_IS_SEQ( (a) )
AUX_ASSERT_IS_SEQ( (a)(b) )
AUX_ASSERT_IS_SEQ( (a)(b)(c) )
AUX_ASSERT_IS_SEQ( SEQ )
return 0;
}
AUX_ASSERT_IS_NOT_SEQ( a )
AUX_ASSERT_IS_SEQ( (a) )
AUX_ASSERT_IS_SEQ( (a)(b) )
AUX_ASSERT_IS_SEQ( (a)(b)(c) )
AUX_ASSERT_IS_SEQ( SEQ )
+18 -23
View File
@@ -1,20 +1,20 @@
// + file: libs/mpl/test/aux_/token_eqaul.cpp
// + last modified: 03/may/03
// Copyright (c) 2003
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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/aux_/preprocessor/token_equal.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/preprocessor/logical/not.hpp"
#include "boost/preprocessor/debug/assert.hpp"
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
#include <boost/preprocessor/logical/not.hpp>
#include <boost/preprocessor/debug/assert.hpp>
#define AUX_ASSERT_EQUAL(x, y) \
BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) \
@@ -24,18 +24,13 @@
BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) ) \
/**/
int main()
{
#define BOOST_MPL_PP_TOKEN_EQUAL_apple(x) x
#define BOOST_MPL_PP_TOKEN_EQUAL_orange(x) x
#define BOOST_MPL_PP_TOKEN_EQUAL_apple(x) x
#define BOOST_MPL_PP_TOKEN_EQUAL_orange(x) x
AUX_ASSERT_NOT_EQUAL( apple, abc )
AUX_ASSERT_NOT_EQUAL( abc, apple )
AUX_ASSERT_NOT_EQUAL( apple, orange )
AUX_ASSERT_NOT_EQUAL( orange, apple )
AUX_ASSERT_NOT_EQUAL( apple, abc )
AUX_ASSERT_NOT_EQUAL( abc, apple )
AUX_ASSERT_NOT_EQUAL( apple, orange )
AUX_ASSERT_NOT_EQUAL( orange, apple )
AUX_ASSERT_EQUAL( apple, apple )
AUX_ASSERT_EQUAL( orange, orange )
return 0;
}
AUX_ASSERT_EQUAL( apple, apple )
AUX_ASSERT_EQUAL( orange, orange )
+15 -19
View File
@@ -1,35 +1,31 @@
// + file: libs/mpl/test/aux_/template_arity.cpp
// + last modified: 10/jul/03
// Copyright (c) 2000-03
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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/aux_/template_arity.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
# if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
#include <boost/mpl/aux_/template_arity.hpp>
#include <boost/mpl/aux_/test.hpp>
using namespace boost::mpl;
#if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING)
struct my {};
template< typename T1 > struct my1 {};
template< typename T1, typename T2 = void > struct my2 {};
int main()
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT((aux::template_arity<my>::value == -1));
BOOST_STATIC_ASSERT((aux::template_arity< my1<int> >::value == 1));
BOOST_STATIC_ASSERT((aux::template_arity< my2<int,long> >::value == 2));
BOOST_STATIC_ASSERT((aux::template_arity< my2<int> >::value == 2));
return 0;
MPL_ASSERT_RELATION( (aux::template_arity<my>::value), ==, -1 );
MPL_ASSERT_RELATION( (aux::template_arity< my1<int> >::value), ==, 1 );
MPL_ASSERT_RELATION( (aux::template_arity< my2<int,long> >::value), ==, 2 );
MPL_ASSERT_RELATION( (aux::template_arity< my2<int> >::value), ==, 2 );
}
# endif
#endif
-38
View File
@@ -1,38 +0,0 @@
// + file: libs/mpl/aux_/test/test_case.cpp
// + last modified: 03/may/03
// Copyright (c) 2002-03
// Aleksey Gurtovoy
//
// 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/aux_/test.hpp"
CTT_test_case( false_positives, (S)(T) )
{
CTT_assert_same( 2, (S, char) );
CTT_assert_not_same( 2, (S, bool) );
//T t;
}
CTT_test_case( empty_set, (T) )
{
CTT_for_each(
(T)(T const)
, false_positives
, (char)(_1)
);
}
int main()
{
CTT_test( empty_set, (bool) );
CTT_for_each( (int)(long), empty_set, (_1) );
return 0;
}
-44
View File
@@ -1,44 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/typeof.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002
// Aleksey Gurtovoy
//
// 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)
#include "boost/mpl/aux_/typeof.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace {
template< typename T > struct identity { static T type(); };
}
#define TYPEOF_CHECK(T) \
BOOST_MPL_ASSERT_IS_SAME( \
BOOST_MPL_AUX_TYPEOF(identity<T>::type()) \
, T \
) \
/**/
int main()
{
TYPEOF_CHECK(bool);
TYPEOF_CHECK(signed char);
TYPEOF_CHECK(unsigned char);
TYPEOF_CHECK(char);
TYPEOF_CHECK(short);
TYPEOF_CHECK(unsigned short);
TYPEOF_CHECK(int);
TYPEOF_CHECK(unsigned int);
TYPEOF_CHECK(long);
TYPEOF_CHECK(unsigned long);
TYPEOF_CHECK(float);
TYPEOF_CHECK(double);
TYPEOF_CHECK(long double);
return 0;
}
+21 -23
View File
@@ -1,31 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/back.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/back.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/back.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
template< typename Seq, int value > struct back_test
{
typedef mpl::range_c<int,0,1> range1;
typedef mpl::range_c<int,0,10> range2;
typedef mpl::range_c<int,-10,0> range3;
BOOST_STATIC_ASSERT(mpl::back<range1>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::back<range2>::type::value == 9);
BOOST_STATIC_ASSERT(mpl::back<range3>::type::value == -1);
typedef typename back<Seq>::type t;
MPL_ASSERT_RELATION( t::value, ==, value );
};
return 0;
MPL_TEST_CASE()
{
back_test< range_c<int,0,1>, 0 >();
back_test< range_c<int,0,10>, 9 >();
back_test< range_c<int,-10,0>, -1 >();
}
+60 -27
View File
@@ -1,21 +1,26 @@
//-----------------------------------------------------------------------------
// boost mpl/test/bind.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Peter Dimov 2001-2002
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-02
// Peter Dimov, 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/bind.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/type_traits/is_same.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/bind.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/apply_wrap.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
namespace {
@@ -38,19 +43,47 @@ struct f5
} // namespace
int main()
MPL_TEST_CASE() // basic argument binding
{
using namespace mpl::placeholders;
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 mpl::apply1< mpl::bind1<f1,_1>,int >::type r11;
typedef mpl::apply5< mpl::bind1<f1,_5>,void,void,void,void,int >::type r12;
BOOST_MPL_ASSERT_IS_SAME(r11,int);
BOOST_MPL_ASSERT_IS_SAME(r12,int);
typedef mpl::apply5< mpl::bind5<f5,_1,_2,_3,_4,_5>,void,void,void,void,int >::type r51;
typedef mpl::apply5< mpl::bind5<f5,_5,_4,_3,_2,_1>,int,void,void,void,void >::type r52;
BOOST_MPL_ASSERT_IS_SAME(r51,int);
BOOST_MPL_ASSERT_IS_SAME(r52,int);
return 0;
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() // 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() // 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> ));
}
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) \
&& !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
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> > ));
}
#endif
+58 -53
View File
@@ -1,66 +1,71 @@
// + file: libs/mpl/test/bitwise.cpp
// + last modified: 09/mar/03
// Copyright (c) 2001-03
// Aleksey Gurtovoy, Jaap Suter
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright Jaap Suter 2003
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appears in all copies and
// that both the copyright notice and this permission notice appear in
// supporting documentation. No representations are made about the
// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
// 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/bitwise.hpp"
#include "boost/mpl/integral_c.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/bitwise.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
typedef integral_c<unsigned int, 0> _0;
typedef integral_c<unsigned int, 1> _1;
typedef integral_c<unsigned int, 2> _2;
typedef integral_c<unsigned int, 8> _8;
typedef integral_c<unsigned int, 0xffffffff> _ffffffff;
MPL_TEST_CASE()
{
typedef mpl::integral_c<unsigned int, 0> _0;
typedef mpl::integral_c<unsigned int, 1> _1;
typedef mpl::integral_c<unsigned int, 2> _2;
typedef mpl::integral_c<unsigned int, 8> _8;
typedef mpl::integral_c<unsigned int, 0xFFFFFFFF> _FFFFFFFF;
MPL_ASSERT_RELATION( (bitand_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_1,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_0,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_0,_ffffffff>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitand_<_1,_ffffffff>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitand_<_8,_ffffffff>::value), ==, 8 );
}
BOOST_STATIC_ASSERT((mpl::bitand_<_0,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitand_<_1,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitand_<_0,_1>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitand_<_0,_FFFFFFFF>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitand_<_1,_FFFFFFFF>::value == 1));
BOOST_STATIC_ASSERT((mpl::bitand_<_8,_FFFFFFFF>::value == 8));
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (bitor_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitor_<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitor_<_0,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitor_<_0,_ffffffff>::value), ==, 0xffffffff );
MPL_ASSERT_RELATION( (bitor_<_1,_ffffffff>::value), ==, 0xffffffff );
MPL_ASSERT_RELATION( (bitor_<_8,_ffffffff>::value), ==, 0xffffffff );
}
BOOST_STATIC_ASSERT((mpl::bitor_<_0,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitor_<_1,_0>::value == 1));
BOOST_STATIC_ASSERT((mpl::bitor_<_0,_1>::value == 1));
BOOST_STATIC_ASSERT((mpl::bitor_<_0,_FFFFFFFF>::value == 0xFFFFFFFF));
BOOST_STATIC_ASSERT((mpl::bitor_<_1,_FFFFFFFF>::value == 0xFFFFFFFF));
BOOST_STATIC_ASSERT((mpl::bitor_<_8,_FFFFFFFF>::value == 0xFFFFFFFF));
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (bitxor_<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (bitxor_<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitxor_<_0,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( (bitxor_<_0,_ffffffff>::value), ==, (0xffffffff ^ 0) );
MPL_ASSERT_RELATION( (bitxor_<_1,_ffffffff>::value), ==, (0xffffffff ^ 1) );
MPL_ASSERT_RELATION( (bitxor_<_8,_ffffffff>::value), ==, (0xffffffff ^ 8) );
}
BOOST_STATIC_ASSERT((mpl::bitxor_<_0,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::bitxor_<_1,_0>::value == 1));
BOOST_STATIC_ASSERT((mpl::bitxor_<_0,_1>::value == 1));
BOOST_STATIC_ASSERT((mpl::bitxor_<_0,_FFFFFFFF>::value == (0xFFFFFFFF ^ 0)));
BOOST_STATIC_ASSERT((mpl::bitxor_<_1,_FFFFFFFF>::value == (0xFFFFFFFF ^ 1)));
BOOST_STATIC_ASSERT((mpl::bitxor_<_8,_FFFFFFFF>::value == (0xFFFFFFFF ^ 8)));
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (shift_right<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_right<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_right<_1,_1>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_right<_2,_1>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_right<_8,_1>::value), ==, 4 );
}
BOOST_STATIC_ASSERT((mpl::shift_right<_0,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::shift_right<_1,_0>::value == 1));
BOOST_STATIC_ASSERT((mpl::shift_right<_1,_1>::value == 0));
BOOST_STATIC_ASSERT((mpl::shift_right<_2,_1>::value == 1));
BOOST_STATIC_ASSERT((mpl::shift_right<_8,_1>::value == 4));
BOOST_STATIC_ASSERT((mpl::shift_left<_0,_0>::value == 0));
BOOST_STATIC_ASSERT((mpl::shift_left<_1,_0>::value == 1));
BOOST_STATIC_ASSERT((mpl::shift_left<_1,_1>::value == 2));
BOOST_STATIC_ASSERT((mpl::shift_left<_2,_1>::value == 4));
BOOST_STATIC_ASSERT((mpl::shift_left<_8,_1>::value == 16));
return 0;
MPL_TEST_CASE()
{
MPL_ASSERT_RELATION( (shift_left<_0,_0>::value), ==, 0 );
MPL_ASSERT_RELATION( (shift_left<_1,_0>::value), ==, 1 );
MPL_ASSERT_RELATION( (shift_left<_1,_1>::value), ==, 2 );
MPL_ASSERT_RELATION( (shift_left<_2,_1>::value), ==, 4 );
MPL_ASSERT_RELATION( (shift_left<_8,_1>::value), ==, 16 );
}
+23 -26
View File
@@ -1,34 +1,31 @@
//-----------------------------------------------------------------------------
// boost mpl/test/bool_.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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)
#include "boost/mpl/bool.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <cassert>
namespace mpl = boost::mpl;
#define BOOL_C_TEST(c) \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_<c>::value_type, bool); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_<c>, mpl::c##_); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_<c>::type, mpl::bool_<c>); } \
{ BOOST_STATIC_ASSERT(mpl::bool_<c>::value == c); } \
assert(mpl::bool_<c>() == c); \
#define BOOL_TEST(c) \
{ MPL_ASSERT(( is_same< bool_<c>::value_type, bool > )); } \
{ MPL_ASSERT(( is_same< bool_<c>, c##_ > )); } \
{ MPL_ASSERT(( is_same< bool_<c>::type, bool_<c> > )); } \
{ MPL_ASSERT_RELATION( bool_<c>::value, ==, c ); } \
assert( bool_<c>() == c ); \
/**/
int main()
MPL_TEST_CASE()
{
BOOL_C_TEST(true)
BOOL_C_TEST(false)
return 0;
BOOL_TEST(true)
BOOL_TEST(false)
}
+52 -37
View File
@@ -1,49 +1,64 @@
//-----------------------------------------------------------------------------
// boost mpl/test/comparison.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/comparison.hpp"
#include "boost/mpl/int.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
// make sure MSVC behaves nicely in presence of the following template
template< typename T > struct value {};
typedef int_<0> _0;
typedef int_<10> _10;
MPL_TEST_CASE()
{
typedef mpl::int_<0> _0;
typedef mpl::int_<10> _10;
MPL_ASSERT_NOT(( equal_to<_0, _10> ));
MPL_ASSERT_NOT(( equal_to<_10, _0> ));
MPL_ASSERT(( equal_to<_10, _10> ));
}
BOOST_STATIC_ASSERT((mpl::less<_0, _10>::value));
BOOST_STATIC_ASSERT((!mpl::less<_10, _0>::value));
BOOST_STATIC_ASSERT((!mpl::less<_10, _10>::value));
MPL_TEST_CASE()
{
MPL_ASSERT(( not_equal_to<_0, _10> ));
MPL_ASSERT(( not_equal_to<_10, _0> ));
MPL_ASSERT_NOT(( not_equal_to<_10, _10> ));
}
BOOST_STATIC_ASSERT((mpl::less_equal<_0, _10>::value));
BOOST_STATIC_ASSERT((!mpl::less_equal<_10, _0>::value));
BOOST_STATIC_ASSERT((mpl::less_equal<_10, _10>::value));
MPL_TEST_CASE()
{
MPL_ASSERT(( less<_0, _10> ));
MPL_ASSERT_NOT(( less<_10, _0> ));
MPL_ASSERT_NOT(( less<_10, _10> ));
}
BOOST_STATIC_ASSERT((mpl::greater<_10, _0>::value));
BOOST_STATIC_ASSERT((!mpl::greater<_0, _10>::value));
BOOST_STATIC_ASSERT((!mpl::greater<_10, _10>::value));
MPL_TEST_CASE()
{
MPL_ASSERT(( less_equal<_0, _10> ));
MPL_ASSERT_NOT(( less_equal<_10, _0> ));
MPL_ASSERT(( less_equal<_10, _10> ));
}
BOOST_STATIC_ASSERT((!mpl::greater_equal<_0, _10>::value));
BOOST_STATIC_ASSERT((mpl::greater_equal<_10, _0>::value));
BOOST_STATIC_ASSERT((mpl::greater_equal<_10, _10>::value));
MPL_TEST_CASE()
{
MPL_ASSERT(( greater<_10, _0> ));
MPL_ASSERT_NOT(( greater<_0, _10> ));
MPL_ASSERT_NOT(( greater<_10, _10> ));
}
BOOST_STATIC_ASSERT((!mpl::equal_to<_0, _10>::value));
BOOST_STATIC_ASSERT((!mpl::equal_to<_10, _0>::value));
BOOST_STATIC_ASSERT((mpl::equal_to<_10, _10>::value));
BOOST_STATIC_ASSERT((mpl::not_equal_to<_0, _10>::value));
BOOST_STATIC_ASSERT((mpl::not_equal_to<_10, _0>::value));
BOOST_STATIC_ASSERT((!mpl::not_equal_to<_10, _10>::value));
return 0;
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( greater_equal<_0, _10> ));
MPL_ASSERT(( greater_equal<_10, _0> ));
MPL_ASSERT(( greater_equal<_10, _10> ));
}
+16 -19
View File
@@ -1,27 +1,24 @@
//-----------------------------------------------------------------------------
// boost mpl/test/contains.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-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/contains.hpp"
#include "boost/mpl/list.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/contains.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list<int,char,long,short,char,long,double,long>::type types;
typedef vector<int,char,long,short,char,long,double,long>::type types;
BOOST_STATIC_ASSERT((mpl::contains< types,short >::type::value));
BOOST_STATIC_ASSERT((!mpl::contains< types,unsigned >::type::value));
return 0;
MPL_ASSERT(( contains< types,short > ));
MPL_ASSERT_NOT(( contains< types,unsigned > ));
}
+37 -28
View File
@@ -1,38 +1,47 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-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/copy.hpp"
#include "boost/mpl/vector/vector10_c.hpp"
#include "boost/mpl/vector.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/push_front.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
using mpl::_;
#include <boost/mpl/copy.hpp>
int main()
#include <boost/mpl/vector/vector20_c.hpp>
#include <boost/mpl/vector/vector0.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::vector10_c<int,9,8,7,6,5,4,3,2,1,0> answer;
typedef mpl::copy<
mpl::range_c<int,0,10>
, mpl::vector<>
, mpl::push_front<_,_>
typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> answer;
typedef copy<
range_c<int,0,10>
, mpl::front_inserter< vector0<> >
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 10);
BOOST_STATIC_ASSERT((mpl::equal< result,answer >::type::value));
MPL_ASSERT_RELATION( size<result>::value, ==, 10 );
MPL_ASSERT(( equal< result,answer > ));
}
return 0;
MPL_TEST_CASE()
{
typedef vector10_c<int,10,11,12,13,14,15,16,17,18,19> numbers;
typedef reverse_copy<
range_c<int,0,10>
, mpl::front_inserter<numbers>
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 20 );
MPL_ASSERT(( equal< result,range_c<int,0,20> > ));
}
-38
View File
@@ -1,38 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy_backward.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/copy_backward.hpp"
#include "boost/mpl/list/list10_c.hpp"
#include "boost/mpl/push_front.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholders;
typedef mpl::list10_c<int,10,11,12,13,14,15,16,17,18,19>::type numbers;
typedef mpl::copy_backward<
mpl::range_c<int,0,10>
, numbers
, mpl::push_front<_,_>
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 20);
BOOST_STATIC_ASSERT((mpl::equal< result,mpl::range_c<int,0,20> >::type::value));
return 0;
}
-39
View File
@@ -1,39 +0,0 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy_backward_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/copy_backward_if.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/push_front.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
typedef mpl::list<int,float,long,float,char,long,double,double>::type types;
typedef mpl::list<float,float,double,double>::type float_types;
typedef mpl::copy_backward_if<
types
, mpl::list0<>
, mpl::push_front<_,_>
, boost::is_float<_>
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 4);
BOOST_STATIC_ASSERT((mpl::equal<result,result>::type::value));
return 0;
}
+43 -29
View File
@@ -1,40 +1,54 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-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/copy_if.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/push_front.hpp"
#include "boost/mpl/less.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/size.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
using mpl::_;
#include <boost/mpl/copy_if.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list_c<int,0,1,2,3,4,5,6,7,8,9>::type numbers;
typedef mpl::list_c<int,4,3,2,1,0>::type answer;
typedef mpl::copy_if<
typedef list10_c<int,0,1,2,3,4,5,6,7,8,9>::type numbers;
typedef list5_c<int,4,3,2,1,0>::type answer;
typedef copy_if<
numbers
, mpl::list0_c<int>
, mpl::push_front<_,_>
, mpl::less<_,mpl::int_<5> >
, less<_,int_<5> >
, mpl::front_inserter< list0_c<int> >
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 5);
BOOST_STATIC_ASSERT((mpl::equal<result,answer>::type::value));
MPL_ASSERT_RELATION(size<result>::value, ==, 5);
MPL_ASSERT(( equal<result,answer> ));
}
return 0;
MPL_TEST_CASE()
{
typedef list8<int,float,long,float,char,long,double,double>::type types;
typedef list4<float,float,double,double>::type float_types;
typedef reverse_copy_if<
types
, is_float<_>
, mpl::front_inserter< list0<> >
>::type result;
MPL_ASSERT_RELATION(mpl::size<result>::value, ==, 4);
MPL_ASSERT(( equal<result,float_types> ));
}
+32 -30
View File
@@ -1,39 +1,41 @@
//-----------------------------------------------------------------------------
// boost mpl/test/count.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/count.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/int.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/count.hpp>
int main()
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,char,long,short,char,long,double,long> types;
typedef mpl::list_c<int,1,0,5,1,7,5,0,5> values;
typedef vector<int,char,long,short,char,long,double,long> types;
BOOST_STATIC_ASSERT((mpl::count<types,int>::type::value == 1));
BOOST_STATIC_ASSERT((mpl::count<types,double>::type::value == 1));
BOOST_STATIC_ASSERT((mpl::count<types,char>::type::value == 2));
BOOST_STATIC_ASSERT((mpl::count<types,long>::type::value == 3));
BOOST_STATIC_ASSERT((mpl::count<types,unsigned>::type::value == 0));
MPL_ASSERT_RELATION( (count<types,int>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<types,double>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<types,char>::value), ==, 2 );
MPL_ASSERT_RELATION( (count<types,long>::value), ==, 3 );
MPL_ASSERT_RELATION( (count<types,unsigned>::value), ==, 0 );
}
BOOST_STATIC_ASSERT((mpl::count< values, mpl::integral_c<int,1> >::type::value == 2));
BOOST_STATIC_ASSERT((mpl::count< values, mpl::integral_c<int,0> >::type::value == 2));
BOOST_STATIC_ASSERT((mpl::count< values, mpl::integral_c<int,5> >::type::value == 3));
BOOST_STATIC_ASSERT((mpl::count< values, mpl::integral_c<int,7> >::type::value == 1));
BOOST_STATIC_ASSERT((mpl::count< values, mpl::integral_c<int,8> >::type::value == 0));
return 0;
MPL_TEST_CASE()
{
typedef vector_c<int,1,0,5,1,7,5,0,5> values;
MPL_ASSERT_RELATION( (count< values, integral_c<int,1> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,0> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,5> >::value), ==, 3 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,7> >::value), ==, 1 );
MPL_ASSERT_RELATION( (count< values, integral_c<int,8> >::value), ==, 0 );
}
+27 -30
View File
@@ -1,39 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/count_if.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/count_if.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/less.hpp"
#include "boost/mpl/equal_to.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/count_if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef mpl::list<int,char&,long,short,char&,long,double,long> types;
typedef mpl::list_c<int,1,0,5,1,7,5,0,5> values;
typedef vector<int,char&,long,short,char&,long,double,long> types;
typedef vector_c<int,1,0,5,1,7,5,0,5> values;
BOOST_STATIC_ASSERT((mpl::count_if< types, boost::is_float<_> >::type::value == 1));
BOOST_STATIC_ASSERT((mpl::count_if< types, boost::is_same<_,char&> >::type::value == 2));
BOOST_STATIC_ASSERT((mpl::count_if< types, boost::is_same<_,void*> >::type::value == 0));
MPL_ASSERT_RELATION( (count_if< types, boost::is_float<_> >::value), ==, 1 );
MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,char&> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,void*> >::value), ==, 0 );
BOOST_STATIC_ASSERT((mpl::count_if< values, mpl::lt<5> >::type::value == 4));
BOOST_STATIC_ASSERT((mpl::count_if< values, mpl::eq<0> >::type::value == 2));
BOOST_STATIC_ASSERT((mpl::count_if< values, mpl::eq<-1> >::type::value == 0));
return 0;
MPL_ASSERT_RELATION( (count_if< values, less<_,int_<5> > >::value), ==, 4 );
MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<0>,_> >::value), ==, 2 );
MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<-1>,_> >::value), ==, 0 );
}
+25 -29
View File
@@ -1,41 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/distance.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/distance.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/range_c.hpp>
void list_distance_test()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<char,short,int,long>::type list;
typedef mpl::begin<list>::type first;
typedef mpl::end<list>::type last;
typedef list<char,short,int,long>::type list;
typedef begin<list>::type first;
typedef end<list>::type last;
BOOST_STATIC_ASSERT((mpl::distance<first,last>::type::value == 4));
MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 4 );
}
void range_distance_test()
MPL_TEST_CASE()
{
typedef mpl::range_c<int,0,10>::type range;
typedef mpl::begin<range>::type first;
typedef mpl::end<range>::type last;
typedef range_c<int,0,10>::type range;
typedef begin<range>::type first;
typedef end<range>::type last;
BOOST_STATIC_ASSERT((mpl::distance<first,last>::type::value == 10));
}
int main()
{
return 0;
MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 10 );
}
+16 -21
View File
@@ -1,28 +1,23 @@
//-----------------------------------------------------------------------------
// boost mpl/test/empty.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/empty.hpp"
#include "boost/mpl/list/list10.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/empty.hpp>
int main()
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list0<> list0;
typedef mpl::list1<char> list1;
BOOST_STATIC_ASSERT((mpl::empty<list0>::type::value == true));
BOOST_STATIC_ASSERT((mpl::empty<list1>::type::value == false));
return 0;
MPL_ASSERT(( empty< list0<> > ));
MPL_ASSERT_NOT(( empty< list1<char> > ));
}
+24 -26
View File
@@ -1,33 +1,31 @@
//-----------------------------------------------------------------------------
// boost mpl/test/equal.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/equal.hpp"
#include "boost/mpl/list.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/equal.hpp>
int main()
#include <boost/mpl/list.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,float,long,double,char,long,double,float> list1;
typedef mpl::list<int,float,long,double,char,long,double,float> list2;
typedef mpl::list<int,float,long,double,char,long,double,short> list3;
typedef mpl::list<int,float,long,double,char,long,double> list4;
BOOST_STATIC_ASSERT((mpl::equal<list1,list2>::type::value == true));
BOOST_STATIC_ASSERT((mpl::equal<list2,list1>::type::value == true));
BOOST_STATIC_ASSERT((mpl::equal<list2,list3>::type::value == false));
BOOST_STATIC_ASSERT((mpl::equal<list3,list4>::type::value == false));
BOOST_STATIC_ASSERT((mpl::equal<list4,list3>::type::value == false));
return 0;
typedef list<int,float,long,double,char,long,double,float> list1;
typedef list<int,float,long,double,char,long,double,float> list2;
typedef list<int,float,long,double,char,long,double,short> list3;
typedef list<int,float,long,double,char,long,double> list4;
MPL_ASSERT(( equal<list1,list2> ));
MPL_ASSERT(( equal<list2,list1> ));
MPL_ASSERT_NOT(( equal<list2,list3> ));
MPL_ASSERT_NOT(( equal<list3,list4> ));
MPL_ASSERT_NOT(( equal<list4,list3> ));
}
+34 -35
View File
@@ -1,46 +1,45 @@
//-----------------------------------------------------------------------------
// boost mpl/test/erase.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/erase.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/find.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/integral_c.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/erase.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list<int,char,long,short,char,long,double,long> types;
typedef mpl::list_c<int,1,0,5,1,7,5,0,5> values;
typedef list<int,char,long,short,char,long,double,long> types;
typedef find<types,short>::type iter;
typedef erase<types, iter>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 7 );
typedef mpl::find<types,short>::type types_iter;
typedef mpl::find< values, mpl::integral_c<int,7> >::type values_iter;
typedef find<result,short>::type result_iter;
MPL_ASSERT(( is_same< result_iter, end<result>::type > ));
}
typedef mpl::erase<types, types_iter>::type result_types;
typedef mpl::erase<values, values_iter>::type result_values;
MPL_TEST_CASE()
{
typedef list_c<int,1,0,5,1,7,5,0,5> values;
typedef find< values, integral_c<int,7> >::type iter;
BOOST_STATIC_ASSERT(mpl::size<result_types>::type::value == 7);
BOOST_STATIC_ASSERT(mpl::size<result_values>::type::value == 7);
typedef erase<values, iter>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 7 );
typedef mpl::find<result_types,short>::type result_types_iter;
typedef mpl::find<result_values, mpl::integral_c<int,7> >::type result_values_iter;
BOOST_MPL_ASSERT_IS_SAME(result_types_iter, mpl::end<result_types>::type);
BOOST_MPL_ASSERT_IS_SAME(result_values_iter, mpl::end<result_values>::type);
return 0;
typedef find<result, integral_c<int,7> >::type result_iter;
MPL_ASSERT(( is_same< result_iter, end<result>::type > ));
}
+23 -28
View File
@@ -1,39 +1,34 @@
//-----------------------------------------------------------------------------
// boost mpl/test/erase_range.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/erase.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/find.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include "boost/config.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/erase.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list<int,char,long,short,unsigned,long,double,long> types;
typedef list<int,char,long,short,unsigned,long,double,long> types;
typedef mpl::find<types,short>::type iter1;
typedef mpl::find<types,double>::type iter2;
typedef find<types,short>::type iter1;
typedef find<types,double>::type iter2;
typedef mpl::erase<types,iter1,iter2>::type result;
typedef erase<types,iter1,iter2>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::type::value == 5);
MPL_ASSERT_RELATION( size<result>::value, ==, 5 );
typedef mpl::find<result,unsigned>::type iter;
BOOST_MPL_ASSERT_IS_SAME(iter, mpl::end<result>::type);
return 0;
typedef find<result,unsigned>::type iter;
MPL_ASSERT(( is_same< iter, end<result>::type > ));
}
+33
View File
@@ -0,0 +1,33 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
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> ));
}
+22 -22
View File
@@ -1,28 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/filter_view.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/filter_view.hpp"
#include "boost/mpl/transform_view.hpp"
#include "boost/mpl/max_element.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/sizeof.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
using mpl::_;
#include <boost/static_assert.hpp>
#include <boost/mpl/filter_view.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,float,long,float,char[50],long double,char> types;
typedef mpl::max_element<
@@ -32,6 +33,5 @@ int main()
>
>::type iter;
BOOST_STATIC_ASSERT((boost::is_same<iter::base::type,long double>::value));
return 0;
MPL_ASSERT((is_same<mpl::deref<iter::base>::type, long double>));
}
+27 -31
View File
@@ -1,41 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/find.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/find.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/distance.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/find.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list<int,char,long,short,char,long,double,long>::type types;
typedef mpl::list_c<int,1,0,5,1,7,5,0,5> values;
typedef list<int,char,long,short,char,long,double,long>::type types;
typedef list_c<int,1,0,5,1,7,5,0,5> values;
typedef mpl::find<types, short>::type types_iter;
typedef mpl::find< values, mpl::integral_c<int,7> >::type values_iter;
typedef find<types, short>::type types_iter;
typedef find< values, integral_c<int,7> >::type values_iter;
BOOST_MPL_ASSERT_IS_SAME(types_iter::type, short);
BOOST_STATIC_ASSERT(values_iter::type::value == 7);
MPL_ASSERT(( is_same<types_iter::type, short> ));
MPL_ASSERT_RELATION( values_iter::type::value, ==, 7 );
typedef mpl::begin<types>::type types_first;
typedef mpl::begin<values>::type values_first;
BOOST_STATIC_ASSERT((mpl::distance< types_first,types_iter >::type::value == 3));
BOOST_STATIC_ASSERT((mpl::distance< values_first,values_iter >::type::value == 4));
return 0;
typedef begin<types>::type types_first;
typedef begin<values>::type values_first;
MPL_ASSERT_RELATION( (mpl::distance< types_first,types_iter >::value), ==, 3 );
MPL_ASSERT_RELATION( (mpl::distance< values_first,values_iter >::value), ==, 4 );
}
+37 -32
View File
@@ -1,41 +1,46 @@
//-----------------------------------------------------------------------------
// boost mpl/test/find_if.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/find_if.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/distance.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/find_if.hpp>
int main()
#include <boost/mpl/vector.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
typedef vector<int,char,long,short,char,long,double,float,char>::type types;
typedef begin<types>::type first_;
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef mpl::list9<int,char,long,short,char,long,double,float,char>::type types;
typedef find_if< types, boost::is_float<_> >::type iter;
MPL_ASSERT(( is_same< iter::type, double > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 6 );
}
typedef mpl::find_if< types, boost::is_float<_> >::type iter1;
typedef mpl::find_if< types, boost::is_same<_,long> >::type iter2;
typedef mpl::find_if< types, boost::is_same<_,void> >::type iter3;
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,long> >::type iter;
MPL_ASSERT(( is_same< iter::type, long > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 2 );
}
BOOST_MPL_ASSERT_IS_SAME(iter1::type, double);
BOOST_MPL_ASSERT_IS_SAME(iter2::type, long);
BOOST_MPL_ASSERT_IS_SAME(iter3, mpl::end<types>::type);
typedef mpl::begin<types>::type first;
BOOST_STATIC_ASSERT((mpl::distance<first,iter1>::type::value == 6));
BOOST_STATIC_ASSERT((mpl::distance<first,iter2>::type::value == 2));
return 0;
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,void> >::type iter;
MPL_ASSERT(( is_same< iter, end<types>::type > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, size<types>::value );
}
+42 -22
View File
@@ -1,35 +1,55 @@
//-----------------------------------------------------------------------------
// boost mpl/test/fold.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/fold.hpp"
#include "boost/mpl/vector.hpp"
#include "boost/mpl/next.hpp"
#include "boost/mpl/if.hpp"
#include "boost/mpl/integral_c.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost::mpl;
#include <boost/mpl/fold.hpp>
#include <boost/mpl/reverse_fold.hpp>
//#include <boost/mpl/vector.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector<long,float,short,double,float,long,long double> types;
typedef list<long,float,short,double,float,long,long double> types;
typedef fold<
types
, integral_c<long, 0>
, int_<0>
, if_< boost::is_float<_2>,next<_1>,_1 >
>::type number_of_floats;
BOOST_STATIC_ASSERT(number_of_floats::value == 4);
MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 );
}
return 0;
MPL_TEST_CASE()
{
typedef list_c<int,5,-1,0,-7,-2,0,-5,4> numbers;
typedef list_c<int,-1,-7,-2,-5> negatives;
typedef reverse_fold<
numbers
, list_c<int>
, if_< less< _2,int_<0> >, push_front<_1,_2>, _1 >
>::type result;
MPL_ASSERT(( equal< result,negatives,equal_to<_1,_2> > ));
}
+23 -22
View File
@@ -1,21 +1,23 @@
//-----------------------------------------------------------------------------
// boost mpl/test/for_each.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// 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
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/mpl/for_each.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/mpl/lambda.hpp"
#include "boost/bind.hpp"
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <iostream>
@@ -24,7 +26,6 @@
#include <cassert>
namespace mpl = boost::mpl;
using mpl::_;
struct type_printer
{
@@ -57,18 +58,18 @@ struct value_printer
int main()
{
typedef mpl::list<char,short,int,long,float,double> types;
mpl::for_each< types,mpl::make_identity<_> >(type_printer(std::cout));
mpl::for_each< types,mpl::make_identity<mpl::_1> >(type_printer(std::cout));
typedef mpl::range_c<int,0,10> numbers;
std::vector<int> v;
#if !defined(__BORLANDC__) && (__BORLANDC__ >= 0x561 && !defined(BOOST_STRICT_CONFIG))
mpl::for_each<numbers,mpl::_>(
#if BOOST_WORKAROUND(__BORLANDC__, >= 0x561)
mpl::for_each<numbers>(
boost::bind(&std::vector<int>::push_back, &v, _1)
);
#else
void (std::vector<int>::* push_back)(int const&) = &std::vector<int>::push_back;
mpl::for_each<numbers,mpl::_>(
mpl::for_each<numbers>(
boost::bind(push_back, &v, _1)
);
#endif
+21 -32
View File
@@ -1,40 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/front.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/front.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/front.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
template< typename Seq, int value > struct front_test
{
typedef mpl::list<long>::type types1;
typedef mpl::list<int,long>::type types2;
typedef mpl::list<char,int,long>::type types3;
typedef typename front<Seq>::type t;
MPL_ASSERT_RELATION( t::value, ==, value );
};
BOOST_MPL_ASSERT_IS_SAME(mpl::front<types1>::type, long);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<types2>::type, int);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<types3>::type, char);
typedef mpl::list_c<int,1>::type values1;
typedef mpl::list_c<int,2,1>::type values2;
typedef mpl::list_c<int,3,2,1>::type values3;
BOOST_STATIC_ASSERT(mpl::front<values1>::type::value == 1);
BOOST_STATIC_ASSERT(mpl::front<values2>::type::value == 2);
BOOST_STATIC_ASSERT(mpl::front<values3>::type::value == 3);
return 0;
MPL_TEST_CASE()
{
front_test< range_c<int,1,10>, 1 >();
front_test< range_c<int,2,10>, 2 >();
front_test< range_c<int,-1,0>, -1 >();
}
+80
View File
@@ -0,0 +1,80 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <boost/mpl/aux_/test.hpp>
BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
struct a1 {};
struct a2 { void xxx(); };
struct a3 { int xxx; };
struct a4 { static int xxx(); };
struct b1 { typedef int xxx; };
struct b2 { struct xxx; };
struct b3 { typedef int& xxx; };
struct b4 { typedef int* xxx; };
struct b5 { typedef int xxx[10]; };
struct b6 { typedef void (*xxx)(); };
struct b7 { typedef void (xxx)(); };
template< typename T > struct outer;
template< typename T > struct inner { typedef typename T::type type; };
// agurt, 15/aug/04: make sure MWCW passes the test in presence of the following
// template
template< typename T > struct xxx;
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( has_xxx<int> ));
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
MPL_ASSERT_NOT(( has_xxx<int&> ));
MPL_ASSERT_NOT(( has_xxx<int*> ));
MPL_ASSERT_NOT(( has_xxx<int[]> ));
MPL_ASSERT_NOT(( has_xxx<int (*)()> ));
MPL_ASSERT_NOT(( has_xxx<a2> ));
MPL_ASSERT_NOT(( has_xxx<a3> ));
MPL_ASSERT_NOT(( has_xxx<a4> ));
MPL_ASSERT_NOT(( has_xxx< enum_ > ));
#endif
MPL_ASSERT_NOT(( has_xxx<a1> ));
MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > ));
MPL_ASSERT_NOT(( has_xxx< incomplete > ));
MPL_ASSERT_NOT(( has_xxx< abstract > ));
MPL_ASSERT_NOT(( has_xxx< noncopyable > ));
MPL_ASSERT(( has_xxx<b1,true> ));
MPL_ASSERT(( has_xxx<b2,true> ));
MPL_ASSERT(( has_xxx<b3,true> ));
MPL_ASSERT(( has_xxx<b4,true> ));
MPL_ASSERT(( has_xxx<b5,true> ));
MPL_ASSERT(( has_xxx<b6,true> ));
MPL_ASSERT(( has_xxx<b7,true> ));
#if !defined(HAS_XXX_ASSERT)
# define HAS_XXX_ASSERT(x) MPL_ASSERT(x)
#endif
HAS_XXX_ASSERT(( has_xxx<b1> ));
HAS_XXX_ASSERT(( has_xxx<b2> ));
HAS_XXX_ASSERT(( has_xxx<b3> ));
HAS_XXX_ASSERT(( has_xxx<b4> ));
HAS_XXX_ASSERT(( has_xxx<b5> ));
HAS_XXX_ASSERT(( has_xxx<b6> ));
HAS_XXX_ASSERT(( has_xxx<b7> ));
}
+24 -17
View File
@@ -1,25 +1,32 @@
//-----------------------------------------------------------------------------
// boost mpl/test/identity.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/apply.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/mpl/assert_is_same.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::apply1< mpl::identity<>, char >::type t1;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
typedef apply1< identity<>, char >::type t1;
typedef apply1< identity<_1>, int >::type t2;
MPL_ASSERT(( is_same< t1, char > ));
MPL_ASSERT(( is_same< t2, int > ));
}
return 0;
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> > ));
}
+21 -24
View File
@@ -1,32 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/if.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/if.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/mpl/assert_is_same.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::if_<mpl::true_,char,long>::type t1;
typedef mpl::if_c<true,char,long>::type t2;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
BOOST_MPL_ASSERT_IS_SAME(t2, char);
typedef if_<true_,char,long>::type t1;
typedef if_c<true,char,long>::type t2;
typedef if_<false_,char,long>::type t3;
typedef if_c<false,char,long>::type t4;
typedef mpl::if_<mpl::false_,char,long>::type t3;
typedef mpl::if_c<false,char,long>::type t4;
BOOST_MPL_ASSERT_IS_SAME(t3, long);
BOOST_MPL_ASSERT_IS_SAME(t4, long);
return 0;
MPL_ASSERT(( is_same<t1, char> ));
MPL_ASSERT(( is_same<t2, char> ));
MPL_ASSERT(( is_same<t3, long> ));
MPL_ASSERT(( is_same<t4, long> ));
}
+23 -26
View File
@@ -1,37 +1,34 @@
//-----------------------------------------------------------------------------
// libs mpl/test/index_of.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Eric Friedman 2003
//
// Copyright (c) 2003
// Eric Friedman
//
// 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/index_of.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/static_assert.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/void.hpp"
namespace mpl = boost::mpl;
#include <boost/mpl/index_of.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/void.hpp>
#include <boost/mpl/aux_/test.hpp>
int test_main(int , char* [])
MPL_TEST_CASE()
{
typedef mpl::list< int, double, float >::type types;
typedef list< int, double, float >::type types;
typedef mpl::index_of< types, int >::type index_of_int;
typedef mpl::index_of< types, double >::type index_of_double;
typedef mpl::index_of< types, float >::type index_of_float;
typedef mpl::index_of< types, char >::type index_of_char;
typedef index_of< types, int >::type index_of_int;
typedef index_of< types, double >::type index_of_double;
typedef index_of< types, float >::type index_of_float;
typedef index_of< types, char >::type index_of_char;
BOOST_STATIC_ASSERT(( index_of_int::value == 0 ));
BOOST_STATIC_ASSERT(( index_of_double::value == 1 ));
BOOST_STATIC_ASSERT(( index_of_float::value == 2 ));
MPL_ASSERT_RELATION( index_of_int::value, ==, 0 );
MPL_ASSERT_RELATION( index_of_double::value, ==, 1 );
MPL_ASSERT_RELATION( index_of_float::value, ==, 2 );
BOOST_STATIC_ASSERT(( mpl::is_void_< index_of_char >::value ));
return 0;
MPL_ASSERT(( is_void_< index_of_char > ));
}
+23 -26
View File
@@ -1,43 +1,40 @@
//-----------------------------------------------------------------------------
// boost mpl/test/inherit.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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)
#include "boost/mpl/inherit.hpp"
#include "boost/mpl/assert_is_same.hpp"
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/aux_/test.hpp>
struct her { typedef her herself; };
struct my { typedef my myself; };
int main()
MPL_TEST_CASE()
{
using namespace boost::mpl;
BOOST_MPL_ASSERT_IS_SAME(inherit<her>::type, her);
MPL_ASSERT(( is_same<inherit<her>::type, her> ));
typedef inherit<her,my>::type her_my1;
BOOST_MPL_ASSERT_IS_SAME(her_my1::herself, her);
BOOST_MPL_ASSERT_IS_SAME(her_my1::myself, my);
MPL_ASSERT(( is_same<her_my1::herself, her> ));
MPL_ASSERT(( is_same<her_my1::myself, my> ));
typedef inherit<empty_base,her>::type her1;
BOOST_MPL_ASSERT_IS_SAME(her1, her);
MPL_ASSERT(( is_same<her1, her> ));
typedef inherit<empty_base,her,empty_base,empty_base>::type her2;
BOOST_MPL_ASSERT_IS_SAME(her2, her);
MPL_ASSERT(( is_same<her2, her> ));
typedef inherit<her,empty_base,my>::type her_my2;
BOOST_MPL_ASSERT_IS_SAME(her_my2::herself, her);
BOOST_MPL_ASSERT_IS_SAME(her_my2::myself, my);
MPL_ASSERT(( is_same<her_my2::herself, her> ));
MPL_ASSERT(( is_same<her_my2::myself, my> ));
typedef inherit<empty_base,empty_base>::type empty;
BOOST_MPL_ASSERT_IS_SAME(empty, empty_base);
return 0;
MPL_ASSERT(( is_same<empty, empty_base> ));
}
+23 -24
View File
@@ -1,32 +1,31 @@
//-----------------------------------------------------------------------------
// boost mpl/test/insert.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/insert.hpp"
#include "boost/mpl/find.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/insert.hpp>
int main()
#include <boost/mpl/find.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list_c<int,0,1,3,4,5,6,7,8,9> numbers;
typedef mpl::find< numbers,mpl::integral_c<int,3> >::type pos;
typedef mpl::insert< numbers,pos,mpl::integral_c<int,2> >::type range;
typedef vector_c<int,0,1,3,4,5,6,7,8,9> numbers;
typedef find< numbers,integral_c<int,3> >::type pos;
typedef insert< numbers,pos,integral_c<int,2> >::type range;
BOOST_STATIC_ASSERT(mpl::size<range>::type::value == 10);
BOOST_STATIC_ASSERT((mpl::equal< range,mpl::range_c<int,0,10> >::type::value));
return 0;
MPL_ASSERT_RELATION( size<range>::value, ==, 10 );
MPL_ASSERT(( equal< range,range_c<int,0,10> > ));
}
+26 -33
View File
@@ -1,42 +1,35 @@
//-----------------------------------------------------------------------------
// boost mpl/test/insert_range.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/insert_range.hpp"
#include "boost/mpl/find.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list_c<int,0,1,7,8,9> numbers;
typedef mpl::find< numbers,mpl::integral_c<int,7> >::type pos;
typedef mpl::insert_range< numbers,pos,mpl::range_c<int,2,7> >::type range;
typedef vector_c<int,0,1,7,8,9> numbers;
typedef find< numbers,integral_c<int,7> >::type pos;
typedef insert_range< numbers,pos,range_c<int,2,7> >::type range;
BOOST_STATIC_ASSERT(mpl::size<range>::type::value == 10);
BOOST_STATIC_ASSERT((mpl::equal< range,mpl::range_c<int,0,10> >::type::value));
MPL_ASSERT_RELATION( size<range>::value, ==, 10 );
MPL_ASSERT(( equal< range,range_c<int,0,10> > ));
typedef mpl::insert_range<
mpl::list0<>,
mpl::end< mpl::list0<> >::type,
mpl::list<int>
>::type result2;
BOOST_STATIC_ASSERT((mpl::size<result2>::type::value == 1));
return 0;
typedef insert_range< list0<>,end< list0<> >::type,list1<int> >::type result2;
MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
}
+12 -24
View File
@@ -1,36 +1,24 @@
// + file: libs/mpl/int.cpp
// + last modified: 12/apr/03
// Copyright (c) 2001-03
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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/int.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include "boost/preprocessor/repeat.hpp"
// $Source$
// $Date$
// $Revision$
#include <cassert>
#include <boost/mpl/int.hpp>
#include <boost/preprocessor/repeat.hpp>
namespace mpl = boost::mpl;
#include "integral_wrapper_test.hpp"
#define INT_C_TEST(unused1, i, unused2) \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_<i>::value_type, int); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_<i>::type, mpl::int_<i>); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_<i>::next, mpl::int_<i+1>); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_<i>::prior, mpl::int_<i-1>); } \
{ BOOST_STATIC_ASSERT(mpl::int_<i>::value == i); } \
assert(mpl::int_<i>() == i); \
/**/
int main()
MPL_TEST_CASE()
{
BOOST_PP_REPEAT(10, INT_C_TEST, unused)
return 0;
# define WRAPPER(T, i) int_<i>
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
}
+18 -33
View File
@@ -1,42 +1,27 @@
//-----------------------------------------------------------------------------
// boost mpl/test/integral_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/integral_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include "boost/preprocessor/repeat.hpp"
// $Source$
// $Date$
// $Revision$
#include <cassert>
#include <boost/mpl/integral_c.hpp>
#include <boost/preprocessor/repeat.hpp>
namespace mpl = boost::mpl;
#include "integral_wrapper_test.hpp"
#define INTEGRAL_C_TEST(z, i, T) \
{ \
typedef mpl::integral_c<T,i> c##i; \
typedef mpl::integral_c<T,i+1> next_c##i; \
typedef mpl::integral_c<T,i-1> prior_c##i; \
{ BOOST_MPL_ASSERT_IS_SAME(c##i::value_type, T); } \
{ BOOST_MPL_ASSERT_IS_SAME(c##i::type, c##i); } \
{ BOOST_MPL_ASSERT_IS_SAME(c##i::next, next_c##i); } \
{ BOOST_MPL_ASSERT_IS_SAME(c##i::prior, prior_c##i); } \
{ BOOST_STATIC_ASSERT(c##i::value == i); } \
assert(c##i() == i); \
}
/**/
int main()
MPL_TEST_CASE()
{
BOOST_PP_REPEAT(10, INTEGRAL_C_TEST, char)
BOOST_PP_REPEAT(10, INTEGRAL_C_TEST, short)
BOOST_PP_REPEAT(10, INTEGRAL_C_TEST, int)
return 0;
# define WRAPPER(T, i) integral_c<T,i>
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char)
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, short)
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int)
BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, long)
}
+38
View File
@@ -0,0 +1,38 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/next_prior.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <cassert>
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
assert(WRAPPER(T,i)() == i); \
assert(WRAPPER(T,i)::value == i); \
/**/
#else
# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
assert(WRAPPER(T,i)::value == i); \
/**/
#endif
#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::value_type, T > )); } \
{ MPL_ASSERT(( is_same< WRAPPER(T,i)::type, WRAPPER(T,i) > )); } \
{ MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \
{ MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \
{ MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \
INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \
/**/
+25 -27
View File
@@ -1,44 +1,42 @@
//-----------------------------------------------------------------------------
// boost mpl/test/is_placeholder.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/is_placeholder.hpp"
#include "boost/mpl/placeholders.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/preprocessor/repeat.hpp"
#include "boost/preprocessor/inc.hpp"
#include "boost/preprocessor/cat.hpp"
#include "boost/static_assert.hpp"
#include <boost/mpl/is_placeholder.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/aux_/test.hpp>
using namespace boost::mpl;
struct UDT;
#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/cat.hpp>
#define AUX_IS_PLACEHOLDER_TEST(unused1, n, unused2) \
{ BOOST_STATIC_ASSERT(is_placeholder< \
{ MPL_ASSERT(( is_placeholder< \
BOOST_PP_CAT(_,BOOST_PP_INC(n)) \
>::value); } \
> )); } \
/**/
int main()
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT(!is_placeholder<int>::value);
BOOST_STATIC_ASSERT(!is_placeholder<UDT>::value);
BOOST_STATIC_ASSERT(is_placeholder<_>::value);
MPL_ASSERT_NOT(( is_placeholder<int> ));
MPL_ASSERT_NOT(( is_placeholder<UDT> ));
MPL_ASSERT_NOT(( is_placeholder<incomplete> ));
MPL_ASSERT_NOT(( is_placeholder<abstract> ));
MPL_ASSERT_NOT(( is_placeholder<noncopyable> ));
MPL_ASSERT(( is_placeholder<_> ));
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
, AUX_IS_PLACEHOLDER_TEST
, unused
)
return 0;
}
+29 -30
View File
@@ -1,38 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/is_sequence.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2002-2004
//
// Copyright (c) 2002-03
// 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.hpp"
#include "boost/mpl/vector.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/is_sequence.hpp"
#include "boost/static_assert.hpp"
#include <vector>
// $Source$
// $Date$
// $Revision$
using namespace boost::mpl;
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/aux_/test.hpp>
struct UDT {};
int main()
template< typename T > struct std_vector
{
BOOST_STATIC_ASSERT(!is_sequence< std::vector<int> >::value);
BOOST_STATIC_ASSERT(!is_sequence< int >::value);
BOOST_STATIC_ASSERT(!is_sequence< int& >::value);
BOOST_STATIC_ASSERT(!is_sequence< UDT >::value);
BOOST_STATIC_ASSERT(!is_sequence< UDT* >::value);
BOOST_STATIC_ASSERT((is_sequence< range_c<int,0,0> >::value));
BOOST_STATIC_ASSERT(is_sequence< list<> >::value);
BOOST_STATIC_ASSERT(is_sequence< list<int> >::value);
BOOST_STATIC_ASSERT(is_sequence< vector<> >::value);
BOOST_STATIC_ASSERT(is_sequence< vector<int> >::value);
T* begin();
};
return 0;
MPL_TEST_CASE()
{
MPL_ASSERT_NOT(( is_sequence< std_vector<int> > ));
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> > ));
}
+23
View File
@@ -0,0 +1,23 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/iterator_tags.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( less<mpl::forward_iterator_tag,mpl::bidirectional_iterator_tag> ));
MPL_ASSERT(( less<mpl::bidirectional_iterator_tag,mpl::random_access_iterator_tag> ));
}
+19 -22
View File
@@ -1,35 +1,32 @@
// + file: libs/mpl/test/joint_view.cpp
// + last modified: 25/may/03
// Copyright (c) 2001-03
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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/joint_view.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/size.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/joint_view.hpp>
int main()
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::joint_view<
mpl::range_c<int,0,10>
, mpl::range_c<int,10,15>
typedef joint_view<
range_c<int,0,10>
, range_c<int,10,15>
> numbers;
typedef mpl::range_c<int,0,15> answer;
typedef range_c<int,0,15> answer;
BOOST_STATIC_ASSERT((mpl::equal<numbers,answer>::type::value));
BOOST_STATIC_ASSERT((mpl::size<numbers>::value == 15));
return 0;
MPL_ASSERT(( equal<numbers,answer> ));
MPL_ASSERT_RELATION( size<numbers>::value, ==, 15 );
}
+52 -49
View File
@@ -1,75 +1,78 @@
//-----------------------------------------------------------------------------
// boost mpl/test/lambda.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/logical.hpp"
#include "boost/mpl/comparison.hpp"
#include "boost/mpl/lambda.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/mpl/sizeof.hpp"
#include "boost/mpl/apply.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/type_traits/is_same.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/static_assert.hpp"
#include <boost/mpl/logical.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/apply.hpp>
namespace mpl = boost::mpl;
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_float.hpp>
struct my
{
char a[100];
};
int main()
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
// !(x == char) && !(x == double) && x convertible to int || sizeof(x) > 8
typedef mpl::lambda<
mpl::or_<
mpl::and_<
mpl::not_< boost::is_same<_1, char> >
, mpl::not_< boost::is_float<_1> >
typedef lambda<
or_<
and_<
not_< boost::is_same<_1, char> >
, not_< boost::is_float<_1> >
>
, mpl::greater< mpl::sizeof_<_1>, mpl::size_t<8> >
, greater< sizeof_<_1>, mpl::size_t<8> >
>
>::type f1;
>::type f;
BOOST_STATIC_ASSERT((!mpl::apply1<f1,char>::type::value));
BOOST_STATIC_ASSERT((!mpl::apply1<f1,double>::type::value));
BOOST_STATIC_ASSERT((mpl::apply1<f1,long>::type::value));
BOOST_STATIC_ASSERT((mpl::apply1<f1,my>::type::value));
MPL_ASSERT_NOT(( apply_wrap1<f,char> ));
MPL_ASSERT_NOT(( apply_wrap1<f,double> ));
MPL_ASSERT(( apply_wrap1<f,long> ));
MPL_ASSERT(( apply_wrap1<f,my> ));
}
MPL_TEST_CASE()
{
// x == y || x == my || sizeof(x) == sizeof(y)
typedef mpl::lambda<
mpl::or_<
typedef lambda<
or_<
boost::is_same<_1, _2>
, boost::is_same<_2, my>
, mpl::equal_to< mpl::sizeof_<_1>, mpl::sizeof_<_2> >
, equal_to< sizeof_<_1>, sizeof_<_2> >
>
>::type f2;
>::type f;
BOOST_STATIC_ASSERT((!mpl::apply2<f2,double,char>::type::value));
BOOST_STATIC_ASSERT((!mpl::apply2<f2,my,int>::type::value));
BOOST_STATIC_ASSERT((!mpl::apply2<f2,my,char[99]>::type::value));
BOOST_STATIC_ASSERT((mpl::apply2<f2,int,int>::type::value));
BOOST_STATIC_ASSERT((mpl::apply2<f2,my,my>::type::value));
BOOST_STATIC_ASSERT((mpl::apply2<f2,signed long, unsigned long>::type::value));
MPL_ASSERT_NOT(( apply_wrap2<f,double,char> ));
MPL_ASSERT_NOT(( apply_wrap2<f,my,int> ));
MPL_ASSERT_NOT(( apply_wrap2<f,my,char[99]> ));
MPL_ASSERT(( apply_wrap2<f,int,int> ));
MPL_ASSERT(( apply_wrap2<f,my,my> ));
MPL_ASSERT(( apply_wrap2<f,signed long, unsigned long> ));
}
MPL_TEST_CASE()
{
// bind <-> lambda interaction
typedef mpl::lambda< mpl::less<_1,_2> >::type pred;
typedef mpl::bind2< pred, _1, mpl::int_<4> > f3;
typedef lambda< less<_1,_2> >::type pred;
typedef bind2< pred, _1, int_<4> > f;
BOOST_STATIC_ASSERT((mpl::apply1< f3,mpl::int_<3> >::type::value));
return 0;
MPL_ASSERT(( apply_wrap1< f,int_<3> > ));
}
+36 -39
View File
@@ -1,51 +1,48 @@
//-----------------------------------------------------------------------------
// boost mpl/test/lambda_args.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/lambda.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost;
using namespace mpl;
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/gcc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
class C {};
class incomplete;
typedef int C::* mem_ptr;
typedef int (C::* mem_fun_ptr)();
typedef int UDT::* mem_ptr;
typedef int (UDT::* mem_fun_ptr)();
#define AUX_LAMBDA_TEST(T) \
{BOOST_STATIC_ASSERT((apply1<lambda< is_same<_,T> >::type, T>::type::value));} \
{BOOST_STATIC_ASSERT((apply1<lambda< is_same<T,_> >::type, T>::type::value));} \
{BOOST_STATIC_ASSERT((apply2<lambda< is_same<_,_> >::type, T, T>::type::value));} \
{ MPL_ASSERT(( apply1<lambda< is_same<_,T> >::type, T> )); } \
{ MPL_ASSERT(( apply1<lambda< is_same<T,_> >::type, T> )); } \
{ MPL_ASSERT(( apply2<lambda< is_same<_,_> >::type, T, T> )); } \
/**/
int main()
MPL_TEST_CASE()
{
AUX_LAMBDA_TEST(C);
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
AUX_LAMBDA_TEST(incomplete);
AUX_LAMBDA_TEST( UDT );
AUX_LAMBDA_TEST( abstract );
AUX_LAMBDA_TEST( noncopyable );
AUX_LAMBDA_TEST( incomplete );
AUX_LAMBDA_TEST( int );
AUX_LAMBDA_TEST( void );
AUX_LAMBDA_TEST( double );
AUX_LAMBDA_TEST( int& );
AUX_LAMBDA_TEST( int* );
#if !BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \
&& !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
AUX_LAMBDA_TEST( int[] );
#endif
AUX_LAMBDA_TEST(int);
AUX_LAMBDA_TEST(void);
AUX_LAMBDA_TEST(double);
AUX_LAMBDA_TEST(int&);
AUX_LAMBDA_TEST(int*);
// AUX_LAMBDA_TEST(int[]);
AUX_LAMBDA_TEST(int[10]);
AUX_LAMBDA_TEST(int (*)())
AUX_LAMBDA_TEST(mem_ptr);
AUX_LAMBDA_TEST(mem_fun_ptr);
return 0;
AUX_LAMBDA_TEST( int[10] );
AUX_LAMBDA_TEST( int (*)() )
AUX_LAMBDA_TEST( mem_ptr );
AUX_LAMBDA_TEST( mem_fun_ptr );
}
+60 -17
View File
@@ -1,25 +1,68 @@
//-----------------------------------------------------------------------------
// boost mpl/test/list.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.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/list.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list0<> list0;
typedef mpl::list1<char> list1;
typedef mpl::list2<char,long> list2;
typedef mpl::list9<char,char,char,char,char,char,char,char,char> list9;
typedef list0<> l0;
typedef list1<char> l1;
typedef list2<char,long> l2;
typedef list9<char,char,char,char,char,char,char,char,char> l9;
return 0;
MPL_ASSERT_RELATION(size<l0>::value, ==, 0);
MPL_ASSERT_RELATION(size<l1>::value, ==, 1);
MPL_ASSERT_RELATION(size<l2>::value, ==, 2);
MPL_ASSERT_RELATION(size<l9>::value, ==, 9);
MPL_ASSERT(( empty<l0> ));
MPL_ASSERT_NOT(( empty<l1> ));
MPL_ASSERT_NOT(( empty<l2> ));
MPL_ASSERT_NOT(( empty<l9> ));
MPL_ASSERT(( is_same<front<l1>::type,char> ));
MPL_ASSERT(( is_same<front<l2>::type,char> ));
MPL_ASSERT(( is_same<front<l9>::type,char> ));
}
MPL_TEST_CASE()
{
typedef list2<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 list0<> 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> ));
}
+49 -40
View File
@@ -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 > ));
}
+31 -33
View File
@@ -1,43 +1,41 @@
//-----------------------------------------------------------------------------
// boost mpl/test/logical.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/logical.hpp"
#include "boost/mpl/bool.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/logical.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/test.hpp>
struct my;
struct true_ : mpl::true_ {};
struct false_ : mpl::false_ {};
struct unknown;
int main()
using mpl::true_;
using mpl::false_;
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT((mpl::and_< true_,true_ >::value == true));
BOOST_STATIC_ASSERT((mpl::and_< false_,true_ >::value == false));
BOOST_STATIC_ASSERT((mpl::and_< true_,false_ >::value == false));
BOOST_STATIC_ASSERT((mpl::and_< false_,false_ >::value == false));
BOOST_STATIC_ASSERT((mpl::and_< false_,my >::value == false));
BOOST_STATIC_ASSERT((mpl::and_< false_,my,my >::value == false));
MPL_ASSERT(( mpl::and_< true_,true_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,true_ > ));
MPL_ASSERT_NOT(( mpl::and_< true_,false_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,false_ > ));
MPL_ASSERT_NOT(( mpl::and_< false_,unknown > ));
MPL_ASSERT_NOT(( mpl::and_< false_,unknown,unknown > ));
BOOST_STATIC_ASSERT((mpl::or_< true_,true_ >::value == true));
BOOST_STATIC_ASSERT((mpl::or_< false_,true_ >::value == true));
BOOST_STATIC_ASSERT((mpl::or_< true_,false_ >::value == true));
BOOST_STATIC_ASSERT((mpl::or_< false_,false_ >::value == false));
BOOST_STATIC_ASSERT((mpl::or_< true_,my >::value == true));
BOOST_STATIC_ASSERT((mpl::or_< true_,my,my >::value == true));
MPL_ASSERT(( mpl::or_< true_,true_ > ));
MPL_ASSERT(( mpl::or_< false_,true_ > ));
MPL_ASSERT(( mpl::or_< true_,false_ > ));
MPL_ASSERT_NOT(( mpl::or_< false_,false_ > ));
MPL_ASSERT(( mpl::or_< true_,unknown > ));
MPL_ASSERT(( mpl::or_< true_,unknown,unknown > ));
BOOST_STATIC_ASSERT((mpl::not_< true_ >::value == false));
BOOST_STATIC_ASSERT((mpl::not_< false_ >::value == true));
return 0;
MPL_ASSERT_NOT(( mpl::not_< true_ > ));
MPL_ASSERT(( mpl::not_< false_ > ));
}
+21 -22
View File
@@ -1,29 +1,28 @@
//-----------------------------------------------------------------------------
// boost mpl/test/lower_bound.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/lower_bound.hpp"
#include "boost/mpl/distance.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/less.hpp"
#include "boost/mpl/int.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/lower_bound.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list_c<int,1,2,3,3,3,5,8> numbers;
typedef mpl::lower_bound< numbers, mpl::int_<3> >::type iter;
BOOST_STATIC_ASSERT((mpl::distance< mpl::begin<numbers>::type,iter >::type::value == 2));
BOOST_STATIC_ASSERT(iter::type::value == 3);
return 0;
typedef list_c<int,1,2,3,3,3,5,8> numbers;
typedef lower_bound< numbers, int_<4> >::type iter;
MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 );
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}
+171
View File
@@ -0,0 +1,171 @@
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/map.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/has_key.hpp>
#include <boost/mpl/order.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
typedef m_mask<char
, m_item<int,unsigned
, m_item<char,unsigned char
, map0<> > > > m;
#else
typedef m_mask<char
, m_item2<int,unsigned
, m_item1<char,unsigned char
, map0<> > > > m;
#endif
MPL_ASSERT_RELATION( size<m>::type::value, ==, 1 );
MPL_ASSERT_NOT(( empty<m> ));
MPL_ASSERT(( is_same< clear<m>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m,int>::type,unsigned> ));
MPL_ASSERT(( is_same< at<m,char>::type,void_ > ));
MPL_ASSERT(( contains< m,pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m,pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m,pair<char,unsigned char> > ));
MPL_ASSERT_NOT(( has_key<m,char>::type ));
MPL_ASSERT(( has_key<m,int>::type ));
MPL_ASSERT_RELATION( (order<m,int>::type::value), ==, 3 );
MPL_ASSERT(( is_same< item_by_order<m,3>::type,pair<int,unsigned> > ));
MPL_ASSERT(( is_same< order<m,char>::type,void_ > ));
typedef begin<m>::type first;
typedef end<m>::type last;
MPL_ASSERT(( is_same< first::type,pair<int,unsigned> > ));
MPL_ASSERT(( is_same< next<first>::type,last > ));
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
typedef m_item<char,long,m> m2;
#else
typedef m_item3<char,long,m> m2;
#endif
MPL_ASSERT_RELATION( size<m2>::type::value, ==, 2 );
MPL_ASSERT_NOT(( empty<m2>::type ));
MPL_ASSERT(( is_same< clear<m2>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m2,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m2,char>::type,long > ));
MPL_ASSERT(( contains< m2,pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m2,pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m2,pair<char,unsigned char> > ));
MPL_ASSERT(( contains< m2,pair<char,long> > ));
MPL_ASSERT(( has_key<m2,char>::type ));
MPL_ASSERT_NOT(( has_key<m2,long>::type ));
MPL_ASSERT_RELATION( (order<m2,int>::type::value), ==, 3 );
MPL_ASSERT_RELATION( (order<m2,char>::type::value), ==, 4 );
typedef begin<m2>::type first2;
typedef end<m2>::type last2;
MPL_ASSERT(( is_same<first2::type,pair<int,unsigned> > ));
typedef next<first2>::type iter;
MPL_ASSERT(( is_same<iter::type,pair<char,long> > ));
MPL_ASSERT(( is_same< next<iter>::type,last2 > ));
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
typedef insert<m2,pair<int,unsigned> >::type s2_1;
MPL_ASSERT(( is_same<m2,s2_1> ));
typedef insert<m2,pair<long,unsigned> >::type m3;
MPL_ASSERT_RELATION( size<m3>::type::value, ==, 3 );
MPL_ASSERT(( has_key<m3,long>::type ));
MPL_ASSERT(( has_key<m3,int>::type ));
MPL_ASSERT(( has_key<m3,char>::type ));
MPL_ASSERT(( contains< m3,pair<long,unsigned> > ));
MPL_ASSERT(( contains< m3,pair<int,unsigned> > ));
typedef insert<m,pair<char,long> >::type m1;
MPL_ASSERT_RELATION( size<m1>::type::value, ==, 2 );
MPL_ASSERT(( is_same< at<m1,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m1,char>::type,long > ));
MPL_ASSERT(( contains< m1,pair<int,unsigned> > ));
MPL_ASSERT_NOT(( contains< m1,pair<int,int> > ));
MPL_ASSERT_NOT(( contains< m1,pair<char,unsigned char> > ));
MPL_ASSERT(( contains< m1,pair<char,long> > ));
MPL_ASSERT(( is_same< m1,m2 > ));
typedef erase_key<m1,char>::type m_1;
MPL_ASSERT(( is_same<m,m_1> ));
MPL_ASSERT_RELATION( size<m_1>::type::value, ==, 1 );
MPL_ASSERT(( is_same< at<m_1,char>::type,void_ > ));
MPL_ASSERT(( is_same< at<m_1,int>::type,unsigned > ));
typedef erase_key<m3,char>::type m2_1;
MPL_ASSERT_RELATION( size<m2_1>::type::value, ==, 2 );
MPL_ASSERT(( is_same< at<m2_1,char>::type,void_ > ));
MPL_ASSERT(( is_same< at<m2_1,int>::type,unsigned > ));
MPL_ASSERT(( is_same< at<m2_1,long>::type,unsigned > ));
#endif
}
MPL_TEST_CASE()
{
typedef map0<> m;
MPL_ASSERT_RELATION( size<m>::type::value, ==, 0 );
MPL_ASSERT(( empty<m>::type ));
MPL_ASSERT(( is_same< clear<m>::type,map0<> > ));
MPL_ASSERT(( is_same< at<m,char>::type,void_ > ));
MPL_ASSERT_NOT(( has_key<m,char>::type ));
MPL_ASSERT_NOT(( has_key<m,int>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete>::type ));
MPL_ASSERT_NOT(( has_key<m,char const>::type ));
MPL_ASSERT_NOT(( has_key<m,int const>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT const>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete const>::type ));
MPL_ASSERT_NOT(( has_key<m,int*>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT*>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete*>::type ));
MPL_ASSERT_NOT(( has_key<m,int&>::type ));
MPL_ASSERT_NOT(( has_key<m,UDT&>::type ));
MPL_ASSERT_NOT(( has_key<m,incomplete&>::type ));
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
typedef insert<m,pair<char,int> >::type m1;
MPL_ASSERT_RELATION( size<m1>::type::value, ==, 1 );
MPL_ASSERT(( is_same< at<m1,char>::type,int > ));
typedef erase_key<m,char>::type m0_1;
MPL_ASSERT_RELATION( size<m0_1>::type::value, ==, 0 );
MPL_ASSERT(( is_same< at<m0_1,char>::type,void_ > ));
#endif
}
+18 -21
View File
@@ -1,29 +1,26 @@
//-----------------------------------------------------------------------------
// libs mpl/test/max_element.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Eric Friedman 2002-2003
//
// Copyright (c) 2002-2003
// Eric Friedman
//
// 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/max_element.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/static_assert.hpp"
#include "boost/mpl/list_c.hpp"
#include <boost/mpl/max_element.hpp>
namespace mpl = boost::mpl;
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list_c<int, 3, 4, 2, 0, -5, 8, -1, 7>::type numbers;
typedef mpl::max_element< numbers >::type max_it;
typedef max_it::type max_value;
BOOST_STATIC_ASSERT((max_value::value == 8));
return 0;
typedef list_c<int,3,4,2,0,-5,8,-1,7>::type numbers;
typedef max_element< numbers >::type iter;
typedef deref<iter>::type max_value;
MPL_ASSERT_RELATION( max_value::value, ==, 8 );
}
+27
View File
@@ -0,0 +1,27 @@
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/min_max.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
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> > ));
}
+20 -27
View File
@@ -1,29 +1,24 @@
// + file: libs/mpl/test/multiset.cpp
// + last modified: 05/nov/03
// Copyright Aleksey Gurtovoy 2003
// Copyright Aleksey Gurtovoy 2003-2004
//
// Use, modification and distribution are subject to 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)
// 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/multiset/multiset0.hpp"
#include "boost/mpl/insert.hpp"
#include "boost/mpl/count.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost;
using namespace boost::mpl;
#include <boost/mpl/multiset/multiset0.hpp>
struct abstract
{
virtual ~abstract() = 0;
};
#include <boost/mpl/insert.hpp>
#include <boost/mpl/count.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef multiset0<> s0;
typedef insert<s0,int>::type s1;
@@ -31,13 +26,11 @@ int main()
typedef insert<s2,int>::type s3;
typedef insert<s3,abstract>::type s4;
BOOST_STATIC_ASSERT((count<s0,int>::value == 0));
BOOST_STATIC_ASSERT((count<s1,int>::value == 1));
BOOST_STATIC_ASSERT((count<s2,int>::value == 1));
BOOST_STATIC_ASSERT((count<s2,char&>::value == 1));
BOOST_STATIC_ASSERT((count<s3,int>::value == 2));
BOOST_STATIC_ASSERT((count<s3,char&>::value == 1));
BOOST_STATIC_ASSERT((count<s4,abstract>::value == 1));
return 0;
MPL_ASSERT_RELATION( (count<s0,int>::value), ==, 0 );
MPL_ASSERT_RELATION( (count<s1,int>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<s2,int>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<s2,char&>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<s3,int>::value), ==, 2 );
MPL_ASSERT_RELATION( (count<s3,char&>::value), ==, 1 );
MPL_ASSERT_RELATION( (count<s4,abstract>::value), ==, 1 );
}
+22 -25
View File
@@ -1,32 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/next.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/next.hpp"
#include "boost/mpl/prior.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/assert_is_same.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
int main()
#include <boost/mpl/next.hpp>
#include <boost/mpl/prior.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::int_<0> _0;
typedef mpl::int_<1> _1;
typedef mpl::int_<2> _2;
typedef int_<0> _0;
typedef int_<1> _1;
typedef int_<2> _2;
BOOST_MPL_ASSERT_IS_SAME(mpl::next<_0>::type, _1);
BOOST_MPL_ASSERT_IS_SAME(mpl::next<_1>::type, _2);
BOOST_MPL_ASSERT_IS_SAME(mpl::prior<_1>::type, _0);
BOOST_MPL_ASSERT_IS_SAME(mpl::prior<_2>::type, _1);
return 0;
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 > ));
}
+26
View File
@@ -0,0 +1,26 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003
//
// 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.
// $Source$
// $Date$
// $Revision$
// This file tests that we have the right value for
// BOOST_MPL_CFG_NO_HAS_XXX, and that 'has_xxx' doesn't just fail to
// compile arbitrarily.
#include <boost/mpl/aux_/config/has_xxx.hpp>
#if defined(BOOST_MPL_CFG_NO_HAS_XXX)
# define HAS_XXX_ASSERT(x) MPL_ASSERT_NOT(x)
#endif
#include "has_xxx.cpp"
+129
View File
@@ -0,0 +1,129 @@
// Copyright Aleksey Gurtovoy 2003-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/aux_/test.hpp>
struct complex_tag : int_<10> {};
template< typename Re, typename Im > struct complex
{
typedef complex_tag tag;
typedef complex type;
typedef Re real;
typedef Im imag;
};
template< typename C > struct real : C::real {};
template< typename C > struct imag : C::imag {};
namespace boost { namespace mpl {
template<> struct numeric_cast< integral_c_tag,complex_tag >
{
template< typename N > struct apply
: complex< N, integral_c< typename N::value_type, 0 > >
{
};
};
template<>
struct plus_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: complex<
plus< typename N1::real, typename N2::real >
, plus< typename N1::imag, typename N2::imag >
>
{
};
};
template<>
struct times_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: complex<
minus<
times< typename N1::real, typename N2::real >
, times< typename N1::imag, typename N2::imag >
>
, plus<
times< typename N1::real, typename N2::imag >
, times< typename N1::imag, typename N2::real >
>
>
{
};
};
template<>
struct equal_to_impl< complex_tag,complex_tag >
{
template< typename N1, typename N2 > struct apply
: and_<
equal_to< typename N1::real, typename N2::real >
, equal_to< typename N1::imag, typename N2::imag >
>
{
};
};
}}
typedef complex< int_<5>, int_<-1> > c1;
typedef complex< int_<-5>, int_<1> > c2;
MPL_TEST_CASE()
{
typedef plus<c1,c2>::type r1;
MPL_ASSERT_RELATION( real<r1>::value, ==, 0 );
MPL_ASSERT_RELATION( imag<r1>::value, ==, 0 );
typedef plus<c1,c1>::type r2;
MPL_ASSERT_RELATION( real<r2>::value, ==, 10 );
MPL_ASSERT_RELATION( imag<r2>::value, ==, -2 );
typedef plus<c2,c2>::type r3;
MPL_ASSERT_RELATION( real<r3>::value, ==, -10 );
MPL_ASSERT_RELATION( imag<r3>::value, ==, 2 );
}
MPL_TEST_CASE()
{
typedef times<c1,c2>::type r1;
MPL_ASSERT_RELATION( real<r1>::value, ==, -24 );
MPL_ASSERT_RELATION( imag<r1>::value, ==, 10 );
typedef times<c1,c1>::type r2;
MPL_ASSERT_RELATION( real<r2>::value, ==, 24 );
MPL_ASSERT_RELATION( imag<r2>::value, ==, -10 );
typedef times<c2,c2>::type r3;
MPL_ASSERT_RELATION( real<r3>::value, ==, 24 );
MPL_ASSERT_RELATION( imag<r3>::value, ==, -10 );
}
MPL_TEST_CASE()
{
MPL_ASSERT(( equal_to<c1,c1> ));
MPL_ASSERT(( equal_to<c2,c2> ));
MPL_ASSERT_NOT(( equal_to<c1,c2> ));
MPL_ASSERT(( equal_to<c1, complex< long_<5>, long_<-1> > > ));
}
+32
View File
@@ -0,0 +1,32 @@
// Copyright David Abrahams 2003-2004
// Copyright Aleksey Gurtovoy 2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/pair_view.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list10_c<int,0,1,2,3,4,5,6,7,8,9> l1;
typedef list10_c<int,9,8,7,6,5,4,3,2,1,0> l2;
typedef pair_view<l1,l2> view;
MPL_ASSERT_RELATION( front<view>::type::first::value, ==, 0 );
MPL_ASSERT_RELATION( front<view>::type::second::value, ==, 9 );
}
+26 -30
View File
@@ -1,40 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/pop_front.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/pop_front.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/front.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list<long>::type types1;
typedef mpl::list<int,long>::type types2;
typedef mpl::list<char,int,long>::type types3;
typedef list<long>::type types1;
typedef list<int,long>::type types2;
typedef list<char,int,long>::type types3;
typedef mpl::pop_front<types1>::type result1;
typedef mpl::pop_front<types2>::type result2;
typedef mpl::pop_front<types3>::type result3;
typedef pop_front<types1>::type result1;
typedef pop_front<types2>::type result2;
typedef pop_front<types3>::type result3;
BOOST_STATIC_ASSERT(mpl::size<result1>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::size<result2>::type::value == 1);
BOOST_STATIC_ASSERT(mpl::size<result3>::type::value == 2);
MPL_ASSERT_RELATION( size<result1>::value, ==, 0 );
MPL_ASSERT_RELATION( size<result2>::value, ==, 1 );
MPL_ASSERT_RELATION( size<result3>::value, ==, 2 );
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result2>::type, long);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result3>::type, int);
return 0;
MPL_ASSERT(( is_same< front<result2>::type, long > ));
MPL_ASSERT(( is_same< front<result3>::type, int > ));
}
+22
View File
@@ -0,0 +1,22 @@
// Copyright Aleksey Gurtovoy 2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/print.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef print<int>::type t;
}
+30 -31
View File
@@ -1,41 +1,40 @@
//-----------------------------------------------------------------------------
// boost mpl/test/push_front.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/push_front.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/front.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<>::type types1;
typedef mpl::list<long>::type types2;
typedef mpl::list<int,long>::type types3;
typedef mpl::push_front<types1,long>::type result1;
typedef mpl::push_front<types2,int>::type result2;
typedef mpl::push_front<types3,char>::type result3;
typedef push_front<list0<>,long>::type res1;
typedef push_front<list1<long>,int>::type res2;
typedef push_front<list2<int,long>,char>::type res3;
BOOST_STATIC_ASSERT(mpl::size<result1>::type::value == 1);
BOOST_STATIC_ASSERT(mpl::size<result2>::type::value == 2);
BOOST_STATIC_ASSERT(mpl::size<result3>::type::value == 3);
MPL_ASSERT_RELATION( size<res1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<res2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<res3>::value, ==, 3 );
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result1>::type, long);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result2>::type, int);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result3>::type, char);
MPL_ASSERT(( is_same< front<res1>::type, long > ));
MPL_ASSERT(( is_same< front<res2>::type, int > ));
MPL_ASSERT(( is_same< front<res3>::type, char > ));
MPL_ASSERT(( has_push_front< list0<> > ));
MPL_ASSERT(( has_push_front< list1<long> > ));
return 0;
MPL_ASSERT_NOT(( has_push_back< list0<> > ));
}
+21 -21
View File
@@ -1,21 +1,19 @@
//-----------------------------------------------------------------------------
// boost mpl/test/quote.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/quote.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost::mpl;
#include <boost/mpl/quote.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/aux_/test.hpp>
template< typename T > struct f1
{
@@ -27,16 +25,18 @@ template<
>
struct f5
{
#if !defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS)
// no 'type' member!
#else
typedef f5 type;
#endif
};
int main()
MPL_TEST_CASE()
{
typedef apply1< quote1<f1>,int >::type t1;
typedef apply5< quote5<f5>,char,short,int,long,float >::type t5;
typedef quote1<f1>::apply<int>::type t1;
typedef quote5<f5>::apply<char,short,int,long,float>::type t5;
BOOST_STATIC_ASSERT((boost::is_same< t1, int >::value));
BOOST_STATIC_ASSERT((boost::is_same< t5, f5<char,short,int,long,float> >::value));
return 0;
MPL_ASSERT(( boost::is_same< t1, int > ));
MPL_ASSERT(( boost::is_same< t5, f5<char,short,int,long,float> > ));
}
+58 -35
View File
@@ -1,47 +1,70 @@
//-----------------------------------------------------------------------------
// boost mpl/test/range_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/range_c.hpp"
#include "boost/mpl/empty.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/front.hpp"
#include "boost/mpl/back.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::range_c<int,0,0> range0;
typedef mpl::range_c<int,0,1> range1;
typedef mpl::range_c<int,0,10> range10;
typedef range_c<int,0,0> range0;
typedef range_c<int,0,1> range1;
typedef range_c<int,0,10> range10;
BOOST_STATIC_ASSERT(mpl::size<range0>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::size<range1>::type::value == 1);
BOOST_STATIC_ASSERT(mpl::size<range10>::type::value == 10);
MPL_ASSERT_RELATION( size<range0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<range1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<range10>::value, ==, 10 );
BOOST_STATIC_ASSERT(mpl::empty<range0>::type::value);
BOOST_STATIC_ASSERT(!mpl::empty<range1>::type::value);
BOOST_STATIC_ASSERT(!mpl::empty<range10>::type::value);
MPL_ASSERT(( empty<range0> ));
MPL_ASSERT_NOT(( empty<range1> ));
MPL_ASSERT_NOT(( empty<range10> ));
BOOST_MPL_ASSERT_IS_SAME(mpl::begin<range0>::type, mpl::end<range0>::type);
BOOST_MPL_ASSERT_NOT_SAME(mpl::begin<range1>::type, mpl::end<range1>::type);
BOOST_MPL_ASSERT_NOT_SAME(mpl::begin<range10>::type, mpl::end<range10>::type);
MPL_ASSERT(( is_same<begin<range0>::type, end<range0>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > ));
MPL_ASSERT_NOT(( is_same<begin<range10>::type, end<range10>::type > ));
BOOST_STATIC_ASSERT(mpl::front<range1>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::back<range1>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::front<range10>::type::value == 0);
BOOST_STATIC_ASSERT(mpl::back<range10>::type::value == 9);
MPL_ASSERT_RELATION( front<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range1>::type::value, ==, 0 );
MPL_ASSERT_RELATION( front<range10>::type::value, ==, 0 );
MPL_ASSERT_RELATION( back<range10>::type::value, ==, 9 );
}
return 0;
MPL_TEST_CASE()
{
typedef range_c<int,0,10> range10;
typedef begin<range10>::type i0;
typedef next<i0>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
typedef next<i3>::type i4;
typedef next<i4>::type i5;
typedef next<i5>::type i6;
typedef next<i6>::type i7;
typedef next<i7>::type i8;
typedef next<i8>::type i9;
typedef next<i9>::type i10;
MPL_ASSERT_RELATION( deref<i0>::type::value, ==, 0 );
MPL_ASSERT_RELATION( deref<i1>::type::value, ==, 1 );
MPL_ASSERT_RELATION( deref<i2>::type::value, ==, 2 );
MPL_ASSERT_RELATION( deref<i3>::type::value, ==, 3 );
MPL_ASSERT_RELATION( deref<i4>::type::value, ==, 4 );
MPL_ASSERT_RELATION( deref<i5>::type::value, ==, 5 );
MPL_ASSERT_RELATION( deref<i6>::type::value, ==, 6 );
MPL_ASSERT_RELATION( deref<i7>::type::value, ==, 7 );
MPL_ASSERT_RELATION( deref<i8>::type::value, ==, 8 );
MPL_ASSERT_RELATION( deref<i9>::type::value, ==, 9 );
}
+28
View File
@@ -0,0 +1,28 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/remove.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef vector6<int,float,char,float,float,double> types;
typedef mpl::remove< types,float >::type result;
typedef vector3<int,char,double> answer;
MPL_ASSERT(( equal< result,answer > ));
}
+54
View File
@@ -0,0 +1,54 @@
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/remove_if.hpp>
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/list/list10.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list10_c<int,0,1,2,3,4,5,6,7,8,9> numbers;
typedef list5_c<int,4,3,2,1,0>::type answer;
typedef remove_if<
numbers
, greater<_,int_<4> >
, mpl::front_inserter< list0_c<int> >
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 5 );
MPL_ASSERT(( equal<result,answer> ));
}
MPL_TEST_CASE()
{
typedef list8<int,float,long,float,char,long,double,double> types;
typedef list4<int,long,char,long>::type answer;
typedef reverse_remove_if<
types
, is_float<_>
, mpl::front_inserter< list0<> >
>::type result;
MPL_ASSERT_RELATION( size<result>::value, ==, 4 );
MPL_ASSERT(( equal<result,answer> ));
}
+20 -22
View File
@@ -1,29 +1,27 @@
//-----------------------------------------------------------------------------
// boost mpl/test/replace.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy and John R. Bandela
//
// 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/replace.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/replace.hpp>
int main()
#include <boost/mpl/list.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,float,char,float,float,double>::type types;
typedef mpl::replace< types,float,double >::type result;
typedef mpl::list<int,double,char,double,double,double>::type answer;
BOOST_STATIC_ASSERT((mpl::equal< result,answer >::type::value));
return 0;
typedef list<int,float,char,float,float,double> types;
typedef replace< types,float,double >::type result;
typedef list<int,double,char,double,double,double> answer;
MPL_ASSERT(( equal< result,answer > ));
}
+25 -25
View File
@@ -1,33 +1,33 @@
//-----------------------------------------------------------------------------
// boost mpl/test/replace_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright John R. Bandela 2000-2002
// Copyright David Abrahams 2003-2004
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy and John R. Bandela
//
// 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/replace_if.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/greater.hpp"
#include "boost/mpl/equal_to.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/replace_if.hpp>
int main()
#include <boost/mpl/list/list10_c.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef mpl::list_c<int,1,4,5,2,7,5,3,5>::type numbers;
typedef mpl::replace_if< numbers, mpl::gt<4>, mpl::int_<0> >::type result;
typedef list8_c<int,1,4,5,2,7,5,3,5>::type numbers;
typedef replace_if< numbers, greater<_1,int_<4> >, int_<0> >::type result;
typedef mpl::list_c<int,1,4,0,2,0,0,3,0>::type answer;
BOOST_STATIC_ASSERT((mpl::equal< answer,result,mpl::equal_to<_,_> >::type::value));
return 0;
typedef list8_c<int,1,4,0,2,0,0,3,0>::type answer;
MPL_ASSERT(( equal< answer,result,equal_to<_1,_2> > ));
}
+24 -24
View File
@@ -1,32 +1,32 @@
//-----------------------------------------------------------------------------
// boost mpl/test/reverse.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/reverse.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/equal_to.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/reverse.hpp>
int main()
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef mpl::list_c<int,9,8,7,6,5,4,3,2,1,0>::type numbers;
typedef mpl::reverse< numbers >::type result;
typedef list_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
typedef reverse< numbers >::type result;
typedef mpl::range_c<int,0,10> answer;
BOOST_STATIC_ASSERT((mpl::equal< result,answer,mpl::equal_to<_,_> >::type::value));
return 0;
typedef range_c<int,0,10> answer;
MPL_ASSERT(( equal< result,answer,equal_to<_1,_2> > ));
}
+16 -17
View File
@@ -1,24 +1,23 @@
//-----------------------------------------------------------------------------
// boost mpl/test/same_as.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/same_as.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/same_as.hpp>
int main()
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT((mpl::apply1< mpl::same_as<int>,int >::type::value));
BOOST_STATIC_ASSERT((!mpl::apply1< mpl::same_as<int>,long >::type::value));
return 0;
MPL_ASSERT(( apply1< same_as<int>,int > ));
MPL_ASSERT_NOT(( apply1< same_as<int>,long > ));
}
+139 -72
View File
@@ -1,94 +1,161 @@
// + file: libs/mpl/test/set.cpp
// + last modified: 03/may/03
// Copyright (c) 2002-03
// Aleksey Gurtovoy
// Copyright Aleksey Gurtovoy 2003-2004
// Copyright David Abrahams 2003-2004
//
// 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/set/set0.hpp"
#include "boost/mpl/has_key.hpp"
#include "boost/mpl/order.hpp"
#include "boost/mpl/insert.hpp"
#include "boost/mpl/begin_end.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/mpl/aux_/test.hpp"
#include <boost/mpl/set.hpp>
#include <boost/mpl/insert.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/erase_key.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/clear.hpp>
#include <boost/mpl/has_key.hpp>
#include <boost/mpl/order.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/begin_end.hpp>
using namespace boost::mpl;
using namespace boost;
#include <boost/mpl/aux_/test.hpp>
CTT_test_case( false_positives, (S)(T) )
{
CTT_assert(( !has_key<S,T>::type::value )); // notation test
CTT_assert(( !has_key<S,T>::value ));
CTT_assert_same(3, (BOOST_MSVC_TYPENAME order<S,T>::type, void_));
}
CTT_test_case( empty_set, (T) )
{
typedef set0<> s;
CTT_for_each(
(T) CTT_basic_modifiers(T)
, false_positives
, (s)(_1)
);
}
CTT_test_case( one_element_set, (T) )
{
typedef s_item<T, set0<> > s;
CTT_for_each(
CTT_basic_modifiers(T)
, false_positives
, (s)(_1)
);
CTT_assert(( has_key<s,T>::type::value )); // notation test
CTT_assert(( has_key<s,T>::value ));
CTT_assert_equal(3, (order<s,T>::type::value, 1)); // notation test
CTT_assert_equal(3, (order<s,T>::value, 1));
}
CTT_test_case( insertion, (T) )
{
typedef s_item<T, set0<> > s1;
typedef typename insert< set0<>,T >::type s2;
CTT_assert_same(2, (s1, s2));
}
/*
CTT_test_case( erasure, (T) )
MPL_TEST_CASE()
{
typedef s_mask<char,s_item<int,s_item<char, set0<> > > > s;
CTT_TEST_ASSERT(( !has_key<s,char>::type::value ));
CTT_TEST_ASSERT(( has_key<s,int>::type::value ));
CTT_TEST_ASSERT(( order<s,int>::type::value == 1 ));
CTT_TEST_ASSERT(( is_same< order<s,char>::type,void_ >::value ));
MPL_ASSERT_RELATION( size<s>::value, ==, 1 );
MPL_ASSERT_NOT(( empty<s> ));
MPL_ASSERT(( is_same< clear<s>::type, set0<> > ));
MPL_ASSERT(( is_same< at<s,int>::type, int > ));
MPL_ASSERT(( is_same< at<s,char>::type, void_ > ));
MPL_ASSERT_NOT(( has_key<s,char> ));
MPL_ASSERT(( has_key<s,int> ));
MPL_ASSERT_RELATION( (order<s,int>::value), ==, 2 );
MPL_ASSERT(( is_same< order<s,char>::type, void_ > ));
typedef begin<s>::type first;
typedef end<s>::type last;
CTT_TEST_ASSERT(( is_same<first::type,int>::value ));
CTT_TEST_ASSERT(( is_same<first::next,last>::value ));
MPL_ASSERT(( is_same< first::type, int > ));
MPL_ASSERT(( is_same< next<first>::type, last > ));
typedef s_unmask<char,s> s2;
MPL_ASSERT_RELATION( size<s2>::value, ==, 2 );
MPL_ASSERT_NOT(( empty<s2> ));
MPL_ASSERT(( is_same<clear<s2>::type, set0<> > ));
MPL_ASSERT(( is_same<at<s2,int>::type, int > ));
MPL_ASSERT(( is_same<at<s2,char>::type, char > ));
MPL_ASSERT(( has_key<s2,char> ));
MPL_ASSERT_NOT(( has_key<s2,long> ));
MPL_ASSERT_RELATION( (order<s2,int>::value), ==, 2 );
MPL_ASSERT_RELATION( (order<s2,char>::value), ==, 1 );
typedef begin<s2>::type first2;
typedef end<s2>::type last2;
MPL_ASSERT(( is_same< first2::type, int > ));
typedef next<first2>::type iter;
MPL_ASSERT(( is_same< iter::type, char > ));
MPL_ASSERT(( is_same< next<iter>::type, last2 > ));
typedef insert<s2,int>::type s2_1;
MPL_ASSERT(( is_same<s2, s2_1> ));
typedef insert<s2,long>::type s3;
MPL_ASSERT_RELATION( size<s3>::value, ==, 3 );
MPL_ASSERT(( has_key<s3,long> ));
MPL_ASSERT(( has_key<s3,int> ));
MPL_ASSERT(( has_key<s3,char> ));
typedef insert<s,char>::type s1;
MPL_ASSERT_RELATION( size<s1>::value, ==, 2 );
MPL_ASSERT(( is_same<at<s1,int>::type, int > ));
MPL_ASSERT(( is_same<at<s1,char>::type, char > ));
MPL_ASSERT_NOT(( is_same<s1, s2> ));
typedef erase_key<s1,char>::type s_1;
MPL_ASSERT(( is_same<s, s_1> ));
MPL_ASSERT_RELATION( size<s_1>::value, ==, 1 );
MPL_ASSERT(( is_same< at<s_1,char>::type, void_ > ));
MPL_ASSERT(( is_same< at<s_1,int>::type, int > ));
}
*/
int main()
MPL_TEST_CASE()
{
CTT_for_each( CTT_basic_types(), empty_set, (_1));
// CTT_for_each( CTT_basic_types(), one_element_set, (_1));
CTT_for_each( CTT_basic_types(), insertion, (_1));
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_ > ));
return 0;
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()
{
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&> ));
}
+18 -22
View File
@@ -1,34 +1,30 @@
//-----------------------------------------------------------------------------
// boost mpl/test/single_view.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/single_view.hpp"
#include "boost/mpl/size.hpp"
#include "boost/mpl/begin_end.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
using namespace boost::mpl;
#include <boost/mpl/single_view.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef single_view<int> view;
typedef begin<view>::type first;
typedef end<view>::type last;
BOOST_MPL_ASSERT_IS_SAME(first::type,int);
BOOST_MPL_ASSERT_IS_SAME(first::next,last);
BOOST_MPL_ASSERT_IS_SAME(last::prior,first);
MPL_ASSERT(( is_same<first::type,int> ));
MPL_ASSERT(( is_same<first::next,last> ));
MPL_ASSERT(( is_same<last::prior,first> ));
BOOST_STATIC_ASSERT(size<view>::type::value == 1);
return 0;
MPL_ASSERT_RELATION( size<view>::value, ==, 1 );
}
+18 -20
View File
@@ -1,28 +1,26 @@
//-----------------------------------------------------------------------------
// boost mpl/test/size.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/size.hpp"
#include "boost/mpl/list.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/size.hpp>
int main()
#include <boost/mpl/list.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<> empty_list;
typedef mpl::list<char,short,int,long> list;
typedef list<> empty_list;
typedef list<char,short,int,long> list;
BOOST_STATIC_ASSERT((mpl::size<empty_list>::type::value == 0));
BOOST_STATIC_ASSERT((mpl::size<list>::type::value == 4));
return 0;
MPL_ASSERT_RELATION( size<empty_list>::value, ==, 0 );
MPL_ASSERT_RELATION( size<list>::value, ==, 4 );
}
+24
View File
@@ -0,0 +1,24 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include "integral_wrapper_test.hpp"
MPL_TEST_CASE()
{
# define WRAPPER(T, i) mpl::size_t<i>
BOOST_PP_REPEAT_FROM_TO(1, 11, INTEGRAL_WRAPPER_TEST, std::size_t)
}
+16 -18
View File
@@ -1,30 +1,28 @@
//-----------------------------------------------------------------------------
// boost mpl/test/sizeof.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/sizeof.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/aux_/test.hpp>
struct my
{
char a[100];
};
int main()
MPL_TEST_CASE()
{
BOOST_STATIC_ASSERT(mpl::sizeof_<char>::type::value == sizeof(char));
BOOST_STATIC_ASSERT(mpl::sizeof_<int>::type::value == sizeof(int));
BOOST_STATIC_ASSERT(mpl::sizeof_<double>::type::value == sizeof(double));
BOOST_STATIC_ASSERT(mpl::sizeof_<my>::type::value == sizeof(my));
return 0;
MPL_ASSERT_RELATION( sizeof_<char>::value, ==, sizeof(char) );
MPL_ASSERT_RELATION( sizeof_<int>::value, ==, sizeof(int) );
MPL_ASSERT_RELATION( sizeof_<double>::value, ==, sizeof(double) );
MPL_ASSERT_RELATION( sizeof_<my>::value, ==, sizeof(my) );
}
+19 -21
View File
@@ -1,31 +1,29 @@
//-----------------------------------------------------------------------------
// libs mpl/test/sort.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2004
// Copyright David Eric Friedman 2002-2003
//
// Copyright (c) 2002-2003
// Eric Friedman
//
// 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/sort.hpp"
#include <boost/mpl/sort.hpp>
#include "boost/static_assert.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/equal.hpp"
#include <boost/static_assert.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/at.hpp>
namespace mpl = boost::mpl;
#include <boost/mpl/aux_/test.hpp>
int main()
MPL_TEST_CASE()
{
typedef mpl::list_c<int, 3, 4, 0, -5, 8, -1, 7>::type numbers;
typedef mpl::list_c<int, -5, -1, 0, 3, 4, 7, 8>::type manual_result;
typedef list_c<int, 3, 4, 0, -5, 8, -1, 7>::type numbers;
typedef list_c<int, -5, -1, 0, 3, 4, 7, 8>::type manual_result;
typedef mpl::sort< numbers >::type result;
typedef sort< numbers >::type result;
BOOST_STATIC_ASSERT((mpl::equal< result,manual_result >::type::value));
return 0;
MPL_ASSERT(( equal< result,manual_result,equal_to<_1,_2> > ));
}
+33 -42
View File
@@ -1,56 +1,47 @@
//-----------------------------------------------------------------------------
// libs mpl/test/stable_partition.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2004
// Copyright Eric Friedman 2003
//
// Copyright (c) 2003
// Eric Friedman
//
// 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/stable_partition.hpp"
// $Source$
// $Date$
// $Revision$
#include "boost/static_assert.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/equal.hpp"
#include <boost/mpl/stable_partition.hpp>
#include "boost/mpl/less.hpp"
#include "boost/mpl/placeholders.hpp"
#include "boost/mpl/int.hpp"
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
namespace mpl = boost::mpl;
typedef vector_c<int,3,4,0,-5,8,-1,7>::type numbers;
typedef vector_c<int,0,-5,-1>::type manual_first;
typedef vector_c<int,3,4,8,7>::type manual_second;
int main()
MPL_TEST_CASE()
{
typedef mpl::list_c<int, 3, 4, 0, -5, 8, -1, 7>::type numbers;
typedef mpl::list_c<int, 0, -5, -1>::type manual_first;
typedef mpl::list_c<int, 3, 4, 8, 7>::type manual_second;
//////
typedef mpl::stable_partition<
typedef stable_partition<
numbers
, mpl::less< mpl::_, mpl::int_<3> >
>::type result1;
, less< _, int_<3> >
>::type result;
typedef result1::first first1;
BOOST_STATIC_ASSERT((mpl::equal< first1,manual_first >::type::value));
typedef result1::second second1;
BOOST_STATIC_ASSERT((mpl::equal< second1,manual_second >::type::value));
MPL_ASSERT(( equal< result::first,manual_first > ));
MPL_ASSERT(( equal< result::second,manual_second > ));
}
//////
typedef mpl::stable_partition<
MPL_TEST_CASE()
{
typedef stable_partition<
numbers
, mpl::lt< 3 >
>::type result2;
typedef result2::first first2;
BOOST_STATIC_ASSERT((mpl::equal< first2,manual_first >::type::value));
typedef result2::second second2;
BOOST_STATIC_ASSERT((mpl::equal< second2,manual_second >::type::value));
, greater_equal< _, int_<3> >
>::type result;
return 0;
MPL_ASSERT(( equal< result::first,manual_second > ));
MPL_ASSERT(( equal< result::second,manual_first > ));
}
+41 -41
View File
@@ -1,51 +1,51 @@
//-----------------------------------------------------------------------------
// boost mpl/test/transform.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-2004
//
// Copyright (c) 2000-03
// Aleksey Gurtovoy, Dave Abrahams
//
// 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/transform.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/plus.hpp"
#include "boost/type_traits/add_pointer.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/transform.hpp>
int main()
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/mpl/aux_/config/gcc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
#include <boost/type_traits/add_pointer.hpp>
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef list<char,short,int,long,float,double> types;
typedef list<char*,short*,int*,long*,float*,double*> pointers;
{
typedef mpl::list<char,short,int,long,float,double> types;
typedef mpl::list<char*,short*,int*,long*,float*,double*> pointers;
typedef transform1< types,add_pointer<_1> >::type result;
MPL_ASSERT(( equal<result,pointers> ));
}
typedef mpl::transform1< types,boost::add_pointer<_1> >::type result1;
BOOST_STATIC_ASSERT((mpl::equal<result1,pointers>::type::value));
typedef mpl::transform< types,boost::add_pointer<_1> >::type result;
BOOST_STATIC_ASSERT((mpl::equal<result,pointers>::type::value));
}
{
typedef mpl::list_c<long,0,2,4,6,8,10> evens;
typedef mpl::list_c<long,2,3,5,7,11,13> primes;
typedef mpl::list_c<long,2,5,9,13,19,23> sums;
MPL_TEST_CASE()
{
typedef list_c<long,0,2,4,6,8,10> evens;
typedef list_c<long,2,3,5,7,11,13> primes;
typedef list_c<long,2,5,9,13,19,23> sums;
typedef mpl::transform2< evens, primes, mpl::plus<> >::type result1;
BOOST_STATIC_ASSERT((mpl::equal<result1::type,sums::type>::type::value));
typedef mpl::transform< evens, primes, mpl::plus<> >::type result;
BOOST_STATIC_ASSERT((mpl::equal<result::type,sums::type>::type::value));
}
return 0;
typedef transform2< evens, primes, plus<> >::type result;
MPL_ASSERT(( equal< result,sums,equal_to<_1,_2> > ));
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
typedef transform< evens, primes, plus<> >::type result2;
MPL_ASSERT(( is_same<result2,result> ));
#endif
}
+21 -22
View File
@@ -1,31 +1,30 @@
//-----------------------------------------------------------------------------
// boost mpl/test/transform_view.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/transform_view.hpp"
#include "boost/mpl/max_element.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/sizeof.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
using mpl::_;
#include <boost/mpl/transform_view.hpp>
int main()
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/sizeof.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list<int,long,char,char[50],double> types;
typedef mpl::max_element<
mpl::transform_view< types, mpl::sizeof_<_> >
typedef list<int,long,char,char[50],double> types;
typedef max_element<
transform_view< types, sizeof_<_> >
>::type iter;
BOOST_STATIC_ASSERT(iter::type::value == 50);
return 0;
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 50 );
}
+21 -22
View File
@@ -1,30 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/unique.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2000-2004
// Copyright David Abrahams 2003-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/unique.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/unique.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/type_traits/is_same.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
using namespace mpl::placeholders;
typedef mpl::list<int,float,float,char,int,int,int,double>::type types;
typedef mpl::unique<types>::type result;
typedef list<int,float,float,char,int,int,int,double> types;
typedef unique< types, is_same<_1,_2> >::type result;
typedef mpl::list<int,float,char,int,double>::type answer;
BOOST_STATIC_ASSERT((mpl::equal< result,answer >::type::value));
return 0;
typedef list<int,float,char,int,double>::type answer;
MPL_ASSERT(( equal< result,answer > ));
}
+26
View File
@@ -0,0 +1,26 @@
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/unpack_args.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
MPL_TEST_CASE()
{
MPL_ASSERT(( apply1<
unpack_args< is_same<_1,_2> >
, vector2<int,int>
> ));
}
+22 -22
View File
@@ -1,29 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/upper_bound.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
// Copyright Aleksey Gurtovoy 2001-2004
//
// Copyright (c) 2001-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/upper_bound.hpp"
#include "boost/mpl/distance.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/less.hpp"
#include "boost/mpl/int.hpp"
#include "boost/static_assert.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/upper_bound.hpp>
int main()
#include <boost/mpl/distance.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::list_c<int,1,2,3,3,3,5,8> numbers;
typedef mpl::upper_bound< numbers, mpl::int_<3> >::type iter;
BOOST_STATIC_ASSERT((mpl::distance< mpl::begin<numbers>::type,iter >::type::value == 5));
BOOST_STATIC_ASSERT(iter::type::value == 5);
return 0;
typedef list_c<int,1,2,3,3,3,5,8> numbers;
typedef upper_bound< numbers, int_<3> >::type iter;
MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 );
MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 );
}
+85 -17
View File
@@ -1,25 +1,93 @@
//-----------------------------------------------------------------------------
// boost mpl/test/vector.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/vector.hpp"
// $Source$
// $Date$
// $Revision$
namespace mpl = boost::mpl;
#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector/vector10.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/pop_back.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/back.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
int main()
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef mpl::vector0<> vector0;
typedef mpl::vector1<char> vector1;
typedef mpl::vector2<char,long> vector2;
typedef mpl::vector9<char,char,char,char,char,char,char,char,char> vector9;
typedef vector0<> v0;
typedef vector1<char> v1;
typedef vector2<char,long> v2;
typedef vector9<char,char,char,char,char,char,char,char,int> v9;
return 0;
MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );
MPL_ASSERT(( empty<v0> ));
MPL_ASSERT_NOT(( empty<v1> ));
MPL_ASSERT_NOT(( empty<v2> ));
MPL_ASSERT_NOT(( empty<v9> ));
MPL_ASSERT(( is_same< front<v1>::type,char > ));
MPL_ASSERT(( is_same< back<v1>::type,char > ));
MPL_ASSERT(( is_same< front<v2>::type,char > ));
MPL_ASSERT(( is_same< back<v2>::type,long > ));
MPL_ASSERT(( is_same< front<v9>::type,char > ));
MPL_ASSERT(( is_same< back<v9>::type,int > ));
}
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 vector0<> v0;
typedef push_back<v0,int>::type v1;
MPL_ASSERT(( is_same< back<v1>::type,int > ));
typedef push_front<v1,char>::type v2;
MPL_ASSERT(( is_same< back<v2>::type,int > ));
MPL_ASSERT(( is_same< front<v2>::type,char > ));
typedef push_back<v2,long>::type v3;
MPL_ASSERT(( is_same< back<v3>::type,long > ));
}
MPL_TEST_CASE()
{
typedef vector<> v0;
typedef vector<char> v1;
typedef vector<char,long> v2;
typedef vector<char,char,char,char,char,char,char,char,int> v9;
MPL_ASSERT_RELATION( size<v0>::value, ==, 0 );
MPL_ASSERT_RELATION( size<v1>::value, ==, 1 );
MPL_ASSERT_RELATION( size<v2>::value, ==, 2 );
MPL_ASSERT_RELATION( size<v9>::value, ==, 9 );
}
Loaded 100 of 1216 files, more files were not shown because too many files have changed in this diff. Show more