Added libs/mpl

[SVN r15384]
This commit is contained in:
Dave Abrahams committed 2002-09-16 19:25:33 +00:00
1 parent 6ec072c403
commit 01d61922bc
238 files changed
+15885

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
subproject libs/mpl/test ;
# bring in rules for testing
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
include testing.jam ;
compile advance.cpp ;
compile always.cpp ;
compile apply.cpp ;
compile apply_if.cpp ;
compile arithmetic.cpp ;
compile assert_is_same.cpp ;
compile at.cpp ;
compile back.cpp ;
compile bind.cpp ;
compile bool_c.cpp ;
compile comparison.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 erase.cpp ;
compile erase_range.cpp ;
compile filter_view.cpp ;
compile find.cpp ;
compile find_if.cpp ;
compile for_each.cpp ;
compile front.cpp ;
compile identity.cpp ;
compile if.cpp ;
compile insert.cpp ;
compile insert_range.cpp ;
compile int_c.cpp ;
compile integral_c.cpp ;
compile lambda.cpp ;
compile list.cpp ;
compile list_c.cpp ;
compile logical.cpp ;
compile lower_bound.cpp ;
compile meta_fun.cpp ;
compile next.cpp ;
compile pop_front.cpp ;
compile push_front.cpp ;
compile range_c.cpp ;
compile replace.cpp ;
compile replace_if.cpp ;
compile reverse.cpp ;
compile size.cpp ;
compile size_of.cpp ;
compile transform.cpp ;
compile transform_view.cpp ;
compile unique.cpp ;
compile upper_bound.cpp ;
+37
View File
@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/advance.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
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::advance_c<first,10>::type iter1;
typedef mpl::advance_c<last,-10>::type iter2;
BOOST_MPL_ASSERT_IS_SAME(iter1, last);
BOOST_MPL_ASSERT_IS_SAME(iter2, first);
return 0;
}
+46
View File
@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// boost mpl/test/always.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/always.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::always<mpl::true_c> always_true;
typedef mpl::apply1< always_true,mpl::false_c >::type res1;
typedef mpl::apply2< always_true,mpl::false_c,mpl::false_c >::type res2;
typedef mpl::apply3< always_true,mpl::false_c,mpl::false_c,mpl::false_c >::type res3;
BOOST_STATIC_ASSERT(res1::value == true);
BOOST_STATIC_ASSERT(res2::value == true);
BOOST_STATIC_ASSERT(res3::value == true);
typedef mpl::always< mpl::int_c<10> > always_10;
typedef mpl::apply1< always_10,mpl::int_c<0> >::type res4;
typedef mpl::apply2< always_10,mpl::int_c<0>,mpl::int_c<0> >::type res5;
typedef mpl::apply3< always_10,mpl::int_c<0>,mpl::int_c<0>,mpl::int_c<0> >::type res6;
BOOST_STATIC_ASSERT(res4::value == 10);
BOOST_STATIC_ASSERT(res5::value == 10);
BOOST_STATIC_ASSERT(res6::value == 10);
return 0;
}
+115
View File
@@ -0,0 +1,115 @@
//-----------------------------------------------------------------------------
// boost mpl/test/apply.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
#include "boost/mpl/aux_/preprocessor/project1st.hpp"
#include "boost/preprocessor/repeat_2nd.hpp"
#include "boost/preprocessor/comma_if.hpp"
#include "boost/preprocessor/dec.hpp"
#include "boost/preprocessor/if.hpp"
#include "boost/preprocessor/cat.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_2ND(
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()
{
BOOST_PP_REPEAT_2ND(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_N_NAME
)
#if defined(BOOST_MPL_HAS_APPLY)
BOOST_PP_REPEAT_2ND(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_NAME
)
#endif
return 0;
}
+57
View File
@@ -0,0 +1,57 @@
//-----------------------------------------------------------------------------
// 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
//
// 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.
#include "boost/mpl/apply_if.hpp"
#include "boost/mpl/bool_c.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_c
, 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_c
, 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;
}
+53
View File
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
// boost mpl/test/arithmetic.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/arithmetic.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::int_c<0> _0;
typedef mpl::int_c<1> _1;
typedef mpl::int_c<3> _3;
typedef mpl::int_c<10> _10;
BOOST_STATIC_ASSERT((mpl::plus<_0,_10>::value == 10));
BOOST_STATIC_ASSERT((mpl::plus<_10,_0>::value == 10));
BOOST_STATIC_ASSERT((mpl::minus<_0,_10>::value == -10));
BOOST_STATIC_ASSERT((mpl::minus<_10,_0>::value == 10));
BOOST_STATIC_ASSERT((mpl::multiplies<_1,_10>::value == 10));
BOOST_STATIC_ASSERT((mpl::multiplies<_10,_1>::value == 10));
BOOST_STATIC_ASSERT((mpl::divides<_10,_1>::value == 10));
BOOST_STATIC_ASSERT((mpl::divides<_10,_1>::value == 10));
BOOST_STATIC_ASSERT((mpl::modulus<_10,_1>::value == 0));
BOOST_STATIC_ASSERT((mpl::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));
BOOST_STATIC_ASSERT((mpl::negate<_10>::value == -10));
return 0;
}
+32
View File
@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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
//
// 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.
#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;
}
+39
View File
@@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
// boost mpl/test/at.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/at.hpp"
#include "boost/mpl/vector/vector10_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::vector10_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
BOOST_STATIC_ASSERT((mpl::at_c<0, numbers>::type::value == 9));
BOOST_STATIC_ASSERT((mpl::at_c<1, numbers>::type::value == 8));
BOOST_STATIC_ASSERT((mpl::at_c<2, numbers>::type::value == 7));
BOOST_STATIC_ASSERT((mpl::at_c<3, numbers>::type::value == 6));
BOOST_STATIC_ASSERT((mpl::at_c<4, numbers>::type::value == 5));
BOOST_STATIC_ASSERT((mpl::at_c<5, numbers>::type::value == 4));
BOOST_STATIC_ASSERT((mpl::at_c<6, numbers>::type::value == 3));
BOOST_STATIC_ASSERT((mpl::at_c<7, numbers>::type::value == 2));
BOOST_STATIC_ASSERT((mpl::at_c<8, numbers>::type::value == 1));
BOOST_STATIC_ASSERT((mpl::at_c<9, numbers>::type::value == 0));
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// boost mpl/test/back.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/back.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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);
return 0;
}
+60
View File
@@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// boost mpl/test/bind.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Peter Dimov, Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/bind.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/type_traits/is_same.hpp"
namespace mpl = boost::mpl;
namespace {
struct f1
{
template< typename T1 > struct apply
{
typedef T1 type;
};
};
struct f5
{
template< typename T1, typename T2, typename T3, typename T4, typename T5 >
struct apply
{
typedef T5 type;
};
};
} // namespace
int main()
{
using namespace mpl::placeholder;
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;
}
+38
View File
@@ -0,0 +1,38 @@
//-----------------------------------------------------------------------------
// boost mpl/test/bool_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include <cassert>
namespace mpl = boost::mpl;
#define BOOL_C_TEST(c) \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_c<c>::value_type, bool); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_c<c>, mpl::c##_c); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::bool_c<c>::type, mpl::bool_c<c>); } \
{ BOOST_STATIC_ASSERT(mpl::bool_c<c>::value == c); } \
assert(mpl::bool_c<c>() == c); \
/**/
int main()
{
BOOL_C_TEST(true)
BOOL_C_TEST(false)
return 0;
}
+53
View File
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
// boost mpl/test/comparison.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/comparison.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::int_c<0> _0;
typedef mpl::int_c<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));
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));
BOOST_STATIC_ASSERT((mpl::greater<_10, _0>::value));
BOOST_STATIC_ASSERT((!mpl::greater<_0, _10>::value));
BOOST_STATIC_ASSERT((!mpl::greater<_10, _10>::value));
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));
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;
}
+42
View File
@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
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<_,_>
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 10);
BOOST_STATIC_ASSERT((mpl::equal< result,answer >::type::value));
return 0;
}
+42
View File
@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------------
// 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
//
// 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.
#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::placeholder;
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;
}
+43
View File
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// 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
//
// 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.
#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;
}
+44
View File
@@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// boost mpl/test/copy_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/copy_if.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/push_front.hpp"
#include "boost/mpl/comparison/less.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/size.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
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<
numbers
, mpl::list0_c<int>
, mpl::push_front<_,_>
, mpl::less<_,mpl::int_c<5> >
>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::value == 5);
BOOST_STATIC_ASSERT((mpl::equal<result,answer>::type::value));
return 0;
}
+43
View File
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// boost mpl/test/count.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/count.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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;
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));
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;
}
+43
View File
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// boost mpl/test/count_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/count_if.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/comparison/less.hpp"
#include "boost/mpl/comparison/equal_to.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
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;
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));
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;
}
+45
View File
@@ -0,0 +1,45 @@
//-----------------------------------------------------------------------------
// boost mpl/test/distance.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/distance.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/range_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
void list_distance_test()
{
typedef mpl::list<char,short,int,long>::type list;
typedef mpl::begin<list>::type first;
typedef mpl::end<list>::type last;
BOOST_STATIC_ASSERT((mpl::distance<first,last>::type::value == 4));
}
void range_distance_test()
{
typedef mpl::range_c<int,0,10>::type range;
typedef mpl::begin<range>::type first;
typedef mpl::end<range>::type last;
BOOST_STATIC_ASSERT((mpl::distance<first,last>::type::value == 10));
}
int main()
{
return 0;
}
+32
View File
@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// boost mpl/test/empty.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/empty.hpp"
#include "boost/mpl/list/list10.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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;
}
+37
View File
@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/equal.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/equal.hpp"
#include "boost/mpl/list.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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;
}
+50
View File
@@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
// boost mpl/test/erase.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
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 mpl::find<types,short>::type types_iter;
typedef mpl::find< values, mpl::integral_c<int,7> >::type values_iter;
typedef mpl::erase<types, types_iter>::type result_types;
typedef mpl::erase<values, values_iter>::type result_values;
BOOST_STATIC_ASSERT(mpl::size<result_types>::type::value == 7);
BOOST_STATIC_ASSERT(mpl::size<result_values>::type::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;
}
+43
View File
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// boost mpl/test/erase_range.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::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 mpl::erase<types,iter1,iter2>::type result;
BOOST_STATIC_ASSERT(mpl::size<result>::type::value == 5);
typedef mpl::find<result,unsigned>::type iter;
BOOST_MPL_ASSERT_IS_SAME(iter, mpl::end<result>::type);
return 0;
}
+41
View File
@@ -0,0 +1,41 @@
//-----------------------------------------------------------------------------
// boost mpl/test/filter_view.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#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/size_of.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
typedef mpl::list<int,float,long,float,char[50],long double,char> types;
typedef mpl::max_element<
mpl::transform_view<
mpl::filter_view< types,boost::is_float<_> >
, mpl::size_of<_>
>
>::type iter;
BOOST_STATIC_ASSERT((boost::is_same<iter::base::type,long double>::value));
return 0;
}
+45
View File
@@ -0,0 +1,45 @@
//-----------------------------------------------------------------------------
// boost mpl/test/find.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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 mpl::find<types, short>::type types_iter;
typedef mpl::find< values, mpl::integral_c<int,7> >::type values_iter;
BOOST_MPL_ASSERT_IS_SAME(types_iter::type, short);
BOOST_STATIC_ASSERT(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;
}
+45
View File
@@ -0,0 +1,45 @@
//-----------------------------------------------------------------------------
// boost mpl/test/find_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
typedef mpl::list9<int,char,long,short,char,long,double,float,char>::type types;
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;
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;
}
+59
View File
@@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// 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
//
// 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.
#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>
#include <typeinfo>
#include <cassert>
namespace mpl = boost::mpl;
using mpl::_;
struct printer
{
printer(std::ostream& s) : f_stream(&s) {}
template< typename U > void operator()(mpl::identity<U>)
{
*f_stream << typeid(U).name() << '\n';
}
private:
std::ostream* f_stream;
};
int main()
{
typedef mpl::list<char,short,int,long,float,double> types;
mpl::for_each< types,mpl::make_identity<_> >(printer(std::cout));
typedef mpl::range_c<int,0,10> numbers;
std::vector<int> v;
mpl::for_each<numbers,mpl::_>(
boost::bind(&std::vector<int>::push_back, &v, _1)
);
for (int i = 0; i < v.size(); ++i)
assert(v[i] == i);
return 0;
}
+44
View File
@@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// boost mpl/test/front.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::list<long>::type types1;
typedef mpl::list<int,long>::type types2;
typedef mpl::list<char,int,long>::type types3;
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;
}
+29
View File
@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/identity.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/apply.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::apply1< mpl::identity<>, char >::type t1;
BOOST_MPL_ASSERT_IS_SAME(t1, char);
return 0;
}
+36
View File
@@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/if.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::if_<mpl::true_c,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 mpl::if_<mpl::false_c,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;
}
+36
View File
@@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/insert.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
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;
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;
}
+36
View File
@@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/insert_range.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/insert_range.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"
namespace mpl = boost::mpl;
int main()
{
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;
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;
}
+39
View File
@@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
// boost mpl/test/int_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include "boost/preprocessor/repeat.hpp"
#include <cassert>
namespace mpl = boost::mpl;
#define INT_C_TEST(z, i, unused) \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_c<i>::value_type, int); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_c<i>::type, mpl::int_c<i>); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_c<i>::next, mpl::int_c<i+1>); } \
{ BOOST_MPL_ASSERT_IS_SAME(mpl::int_c<i>::prior, mpl::int_c<i-1>); } \
{ BOOST_STATIC_ASSERT(mpl::int_c<i>::value == i); } \
assert(mpl::int_c<i>() == i);
/**/
int main()
{
BOOST_PP_REPEAT(10, INT_C_TEST, unused)
return 0;
}
+46
View File
@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// boost mpl/test/integral_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/integral_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
#include "boost/static_assert.hpp"
#include "boost/preprocessor/repeat.hpp"
#include <cassert>
namespace mpl = boost::mpl;
#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()
{
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;
}
+77
View File
@@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// boost mpl/test/lambda.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/logical.hpp"
#include "boost/mpl/comparison.hpp"
#include "boost/mpl/lambda.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/size_of.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
struct my
{
char a[100];
};
int main()
{
using namespace mpl::placeholder;
// !(x == char) && !(x == double) && x convertible to int || size_of(x) > 8
typedef mpl::lambda<
mpl::logical_or<
mpl::logical_and<
mpl::logical_not< boost::is_same<_1, char> >
, mpl::logical_not< boost::is_float<_1> >
>
, mpl::greater< mpl::size_of<_1>, mpl::int_c<8> >
>
>::type f1;
BOOST_STATIC_ASSERT(!f1::apply<char>::type::value);
BOOST_STATIC_ASSERT(!f1::apply<double>::type::value);
BOOST_STATIC_ASSERT(f1::apply<long>::type::value);
BOOST_STATIC_ASSERT(f1::apply<my>::type::value);
// x == y || x == my || sizeof(x) == sizeof(y)
typedef mpl::lambda<
mpl::logical_or<
boost::is_same<_1, _2>
, boost::is_same<_2, my>
, mpl::equal_to< mpl::size_of<_1>, mpl::size_of<_2> >
>
>::type f2;
BOOST_STATIC_ASSERT((!f2::apply<double,char>::type::value));
BOOST_STATIC_ASSERT((!f2::apply<my,int>::type::value));
BOOST_STATIC_ASSERT((!f2::apply<my,char[99]>::type::value));
BOOST_STATIC_ASSERT((f2::apply<int,int>::type::value));
BOOST_STATIC_ASSERT((f2::apply<my,my>::type::value));
BOOST_STATIC_ASSERT((f2::apply<signed long, unsigned long>::type::value));
// bind <-> lambda interaction
typedef mpl::lambda< mpl::less<_1,_2> >::type pred;
typedef mpl::bind2< pred, _1, mpl::int_c<4> > f3;
BOOST_STATIC_ASSERT((f3::apply< mpl::int_c<3> >::type::value));
return 0;
}
+29
View File
@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------------
// boost mpl/test/list.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/list.hpp"
namespace mpl = boost::mpl;
int main()
{
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;
return 0;
}
+64
View File
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// boost mpl/test/list_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
void test_bool_list()
{
typedef mpl::list_c<bool,true>::type list1;
typedef mpl::list_c<bool,false>::type list2;
BOOST_STATIC_ASSERT(mpl::front<list1>::type::value == true);
BOOST_STATIC_ASSERT(mpl::front<list2>::type::value == false);
}
#endif
void test_int_list()
{
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;
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);
}
void test_unsigned_list()
{
typedef mpl::list_c<unsigned,0>::type list1;
typedef mpl::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);
}
int main()
{
return 0;
}
+47
View File
@@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// boost mpl/test/logical.cpp source file
// See http://www.boost.org for updates,documentation,and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/logical.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
struct my;
struct true_c : mpl::true_c {};
struct false_c : mpl::false_c {};
int main()
{
BOOST_STATIC_ASSERT((mpl::logical_and< true_c,true_c >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_and< false_c,true_c >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_and< true_c,false_c >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_and< false_c,false_c >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_and< false_c,my >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_and< false_c,my,my >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_or< true_c,true_c >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_or< false_c,true_c >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_or< true_c,false_c >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_or< false_c,false_c >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_or< true_c,my >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_or< true_c,my,my >::value == true));
BOOST_STATIC_ASSERT((mpl::logical_not< true_c >::value == false));
BOOST_STATIC_ASSERT((mpl::logical_not< false_c >::value == true));
return 0;
}
+32
View File
@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// boost mpl/test/lower_bound.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/lower_bound.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/comparison/less.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
typedef mpl::list_c<int,1,2,3,3,3,5,8> numbers;
typedef mpl::lower_bound< numbers, mpl::int_c<3>, mpl::less<_,_> >::type iter;
BOOST_STATIC_ASSERT((mpl::distance< mpl::begin<numbers>::type,iter >::type::value == 2));
return 0;
}
+31
View File
@@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// boost mpl/test/meta_fun.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/meta_fun.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace mpl = boost::mpl;
template<typename> struct f1;
template<typename T1, typename T2, typename T3, typename T4, typename T5> struct f5;
int main()
{
typedef mpl::meta_fun1<f1> fc1;
typedef mpl::meta_fun5<f5> fc5;
return 0;
}
+36
View File
@@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/next.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/next.hpp"
#include "boost/mpl/prior.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/assert_is_same.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::int_c<0> _0;
typedef mpl::int_c<1> _1;
typedef mpl::int_c<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;
}
+44
View File
@@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// boost mpl/test/pop_front.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::list<long>::type types1;
typedef mpl::list<int,long>::type types2;
typedef mpl::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;
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);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result2>::type, long);
BOOST_MPL_ASSERT_IS_SAME(mpl::front<result3>::type, int);
return 0;
}
+45
View File
@@ -0,0 +1,45 @@
//-----------------------------------------------------------------------------
// boost mpl/test/push_front.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
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;
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);
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);
return 0;
}
+51
View File
@@ -0,0 +1,51 @@
//-----------------------------------------------------------------------------
// boost mpl/test/range_c.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::range_c<int,0,0> range0;
typedef mpl::range_c<int,0,1> range1;
typedef mpl::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);
BOOST_STATIC_ASSERT(mpl::empty<range0>::type::value);
BOOST_STATIC_ASSERT(!mpl::empty<range1>::type::value);
BOOST_STATIC_ASSERT(!mpl::empty<range10>::type::value);
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);
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);
return 0;
}
+33
View File
@@ -0,0 +1,33 @@
//-----------------------------------------------------------------------------
// boost mpl/test/replace.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy and John R. Bandela
//
// 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.
#include "boost/mpl/replace.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
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;
}
+37
View File
@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// boost mpl/test/replace_if.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy and John R. Bandela
//
// 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.
#include "boost/mpl/replace_if.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/mpl/comparison/greater.hpp"
#include "boost/mpl/comparison/equal_to.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
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_c<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;
}
+36
View File
@@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// boost mpl/test/reverse.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#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/comparison/equal_to.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
typedef mpl::list_c<int,9,8,7,6,5,4,3,2,1,0>::type numbers;
typedef mpl::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;
}
+32
View File
@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// boost mpl/test/size.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/size.hpp"
#include "boost/mpl/list.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
typedef mpl::list<> empty_list;
typedef mpl::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;
}
+34
View File
@@ -0,0 +1,34 @@
//-----------------------------------------------------------------------------
// boost mpl/test/size_of.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/size_of.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
struct my
{
char a[100];
};
int main()
{
BOOST_STATIC_ASSERT(mpl::size_of<char>::type::value == sizeof(char));
BOOST_STATIC_ASSERT(mpl::size_of<int>::type::value == sizeof(int));
BOOST_STATIC_ASSERT(mpl::size_of<double>::type::value == sizeof(double));
BOOST_STATIC_ASSERT(mpl::size_of<my>::type::value == sizeof(my));
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// boost mpl/test/transform.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/transform.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/type_traits/add_pointer.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
typedef mpl::list<char,short,int,long,float,double> types;
typedef mpl::list<char*,short*,int*,long*,float*,double*> pointers;
typedef mpl::transform< types,boost::add_pointer<_1> >::type result;
BOOST_STATIC_ASSERT((mpl::equal<result,pointers>::type::value));
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// boost mpl/test/transform_view.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/transform_view.hpp"
#include "boost/mpl/max_element.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/size_of.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
int main()
{
typedef mpl::list<int,long,char,char[50],double> types;
typedef mpl::max_element<
mpl::transform_view< types, mpl::size_of<_> >
>::type iter;
BOOST_STATIC_ASSERT(iter::type::value == 50);
return 0;
}
+34
View File
@@ -0,0 +1,34 @@
//-----------------------------------------------------------------------------
// boost mpl/test/unique.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2000-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/unique.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/equal.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
int main()
{
using namespace mpl::placeholder;
typedef mpl::list<int,float,float,char,int,int,int,double>::type types;
typedef mpl::unique<types>::type result;
typedef mpl::list<int,float,char,int,double>::type answer;
BOOST_STATIC_ASSERT((mpl::equal< result,answer >::type::value));
return 0;
}
+35
View File
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// boost mpl/test/upper_bound.cpp source file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// 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.
#include "boost/mpl/upper_bound.hpp"
#include "boost/mpl/list_c.hpp"
#include "boost/mpl/comparison/less.hpp"
#include "boost/mpl/int_c.hpp"
#include "boost/mpl/distance.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
using mpl::_;
#define N 50
int main()
{
typedef mpl::list_c<int,1,2,3,3,3,5,8> numbers;
typedef mpl::upper_bound< numbers, mpl::int_c<3>, mpl::less<_,_> >::type iter;
BOOST_STATIC_ASSERT((mpl::distance< mpl::begin<numbers>::type,iter >::type::value == 5));
return 0;
}