merged from main trunk

[SVN r15767]
This commit is contained in:
Aleksey Gurtovoy
2002-10-07 13:10:10 +00:00
parent db832a45e3
commit cb39883773
40 changed files with 46 additions and 147 deletions

View File

@@ -52,7 +52,7 @@ Inline composition is very appealing syntactically when one deals with metafunct
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::size_of<_1>, mpl::int_c<16> >
mpl::less< mpl::sizeof_<_1>, mpl::int_c<16> >
, boost::is_same<_1,_2>
> expr;
@@ -71,7 +71,7 @@ The alternative way to write an equivalent of the above metafunction class would
typedef bind<
mpl::meta_fun2<mpl::logical_or>
, mpl::bind< mpl::meta_fun2<mpl::less>
, mpl::bind< mpl::meta_fun1<mpl::size_of>,_1 >
, mpl::bind< mpl::meta_fun1<mpl::sizeof_>,_1 >
, mpl::int_c<16>
>
, mpl::bind< mpl::meta_fun2<boost::is_same>,_1,_2 >
@@ -89,7 +89,7 @@ For its own metafunctions (algorithms, primitives, etc.), &MPL; enables one to w
<programlisting><![CDATA[
typedef mpl::bind<
mpl::logical_or<>
, mpl::bind< mpl::less<>, mpl::bind<mpl::size_of<>,_1>, mpl::int_c<16> >
, mpl::bind< mpl::less<>, mpl::bind<mpl::sizeof_<>,_1>, mpl::int_c<16> >
, mpl::bind< mpl::make_f2<boost::is_same>, _1,_2 >
> func;
]]></>
@@ -112,7 +112,7 @@ struct my_predicate
};
typedef mpl::logical_or<
mpl::less< mpl::size_of<_>,mpl::int_c<16> >
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, mpl::bind< my_predicate,_,_ > // here
> expr;
]]></>
@@ -123,7 +123,7 @@ To bind something to one of its arguments (or change the order of parameters), t
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::size_of<_>,mpl::int_c<16> >
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, mpl::bind<my_predicate,int,_>::type // here
> expr;
]]></>
@@ -134,7 +134,7 @@ or
<programlisting><![CDATA[
typedef mpl::logical_or<
mpl::less< mpl::size_of<_>,mpl::int_c<16> >
mpl::less< mpl::sizeof_<_>,mpl::int_c<16> >
, my_predicate::apply<int,_> // here
> expr;
]]></>

View File

@@ -183,7 +183,7 @@ struct largest
typedef typename mpl::max_element<
mpl::transform_view<
Sequence
, mpl::size_of<_>
, mpl::sizeof_<_>
>
>::type type;
};
@@ -201,8 +201,8 @@ struct largest
typedef typename mpl::max_element<
Sequence
mpl::less<
mpl::size_of<_1>
, mpl::size_of<_2>
mpl::sizeof_<_1>
, mpl::sizeof_<_2>
>
>::type iter;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list10.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list10_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list20.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list20_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list30.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list30_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list40.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list40_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list50.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/list/list50_c.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector10.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector10_c.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector20.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector20_c.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector30.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector30_c.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector40.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector40_c.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector50.hpp"

View File

@@ -1,3 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#define BOOST_MPL_TYPEOF_BASED_VECTOR_IMPL
#include "boost/mpl/vector/vector50_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector10.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector10_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector20.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector20_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector30.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector30_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector40.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector40_c.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector50.hpp"

View File

@@ -1,2 +0,0 @@
#define BOOST_MPL_PREPROCESSING_MODE
#include "boost/mpl/vector/vector50_c.hpp"

View File

@@ -19,9 +19,8 @@
#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/repeat.hpp"
#include "boost/preprocessor/comma_if.hpp"
#include "boost/preprocessor/dec.hpp"
#include "boost/preprocessor/if.hpp"
@@ -56,7 +55,7 @@ namespace mpl = boost::mpl;
/**/
namespace aux {
BOOST_PP_REPEAT_2ND(
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_FUNC_DEF
, unused
@@ -98,14 +97,14 @@ BOOST_PP_REPEAT_2ND(
int main()
{
BOOST_PP_REPEAT_2ND(
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_N_NAME
)
#if defined(BOOST_MPL_HAS_APPLY)
BOOST_PP_REPEAT_2ND(
BOOST_PP_REPEAT(
BOOST_MPL_METAFUNCTION_MAX_ARITY
, APPLY_TEST
, MAKE_APPLY_NAME

View File

@@ -24,16 +24,16 @@ 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));
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;
}

View File

@@ -18,7 +18,7 @@
#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/mpl/sizeof.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/static_assert.hpp"
@@ -32,7 +32,7 @@ int main()
typedef mpl::max_element<
mpl::transform_view<
mpl::filter_view< types,boost::is_float<_> >
, mpl::size_of<_>
, mpl::sizeof_<_>
>
>::type iter;

View File

@@ -50,6 +50,7 @@ int main()
typedef mpl::list<char,short,int,long,float,double> types;
mpl::for_each< types,mpl::make_identity<_> >(printer(std::cout));
#if !defined(__BORLANDC__) || __BORLANDC__ != 0x560
typedef mpl::range_c<int,0,10> numbers;
std::vector<int> v;
mpl::for_each<numbers,mpl::_>(
@@ -58,6 +59,7 @@ int main()
for (int i = 0; i < v.size(); ++i)
assert(v[i] == i);
#endif
return 0;
}

View File

@@ -19,7 +19,9 @@
#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/mpl/sizeof.hpp"
#include "boost/mpl/apply.hpp"
#include "boost/type_traits/is_same.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/static_assert.hpp"
@@ -35,43 +37,43 @@ int main()
{
using namespace mpl::placeholder;
// !(x == char) && !(x == double) && x convertible to int || size_of(x) > 8
// !(x == char) && !(x == double) && x convertible to int || sizeof(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> >
, mpl::greater< mpl::sizeof_<_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);
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));
// 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> >
, mpl::equal_to< mpl::sizeof_<_1>, mpl::sizeof_<_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));
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));
// 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));
BOOST_STATIC_ASSERT((mpl::apply1< f3,mpl::int_c<3> >::type::value));
return 0;
}

View File

@@ -1,34 +0,0 @@
//-----------------------------------------------------------------------------
// 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;
}

View File

@@ -17,7 +17,7 @@
#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/mpl/sizeof.hpp"
#include "boost/static_assert.hpp"
namespace mpl = boost::mpl;
@@ -27,7 +27,7 @@ int main()
{
typedef mpl::list<int,long,char,char[50],double> types;
typedef mpl::max_element<
mpl::transform_view< types, mpl::size_of<_> >
mpl::transform_view< types, mpl::sizeof_<_> >
>::type iter;
BOOST_STATIC_ASSERT(iter::type::value == 50);