mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-31 21:14:43 +02:00
merged fusion from the trunk
[SVN r63560]
This commit is contained in:
@@ -23,9 +23,11 @@ import testing ;
|
||||
[ run algorithm/find.cpp : : : : ]
|
||||
[ run algorithm/find_if.cpp : : : : ]
|
||||
[ run algorithm/fold.cpp : : : : ]
|
||||
[ run algorithm/fold2.cpp : : : : ]
|
||||
[ run algorithm/for_each.cpp : : : : ]
|
||||
[ run algorithm/insert.cpp : : : : ]
|
||||
[ run algorithm/insert_range.cpp : : : : ]
|
||||
[ run algorithm/iter_fold.cpp : : : : ]
|
||||
[ run algorithm/none.cpp : : : : ]
|
||||
[ run algorithm/pop_back.cpp : : : : ]
|
||||
[ run algorithm/pop_front.cpp : : : : ]
|
||||
@@ -35,6 +37,8 @@ import testing ;
|
||||
[ run algorithm/remove_if.cpp : : : : ]
|
||||
[ run algorithm/replace.cpp : : : : ]
|
||||
[ run algorithm/replace_if.cpp : : : : ]
|
||||
[ run algorithm/reverse_fold.cpp : : : : ]
|
||||
[ run algorithm/reverse_iter_fold.cpp : : : : ]
|
||||
[ run algorithm/reverse.cpp : : : : ]
|
||||
[ run algorithm/transform.cpp : : : : ]
|
||||
[ run algorithm/join.cpp : : : : ]
|
||||
|
@@ -16,8 +16,8 @@ namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
explicit search_for(int in_search)
|
||||
: search(in_search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
|
@@ -17,8 +17,8 @@ namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
explicit search_for(int in_search)
|
||||
: search(in_search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
|
@@ -43,7 +43,7 @@ struct add_ints_only
|
||||
|
||||
template <typename State, typename T>
|
||||
State
|
||||
operator()(State const& state, T const& x) const
|
||||
operator()(State const& state, T const& /*x*/) const
|
||||
{
|
||||
return state;
|
||||
}
|
||||
@@ -81,8 +81,8 @@ struct count_ints
|
||||
typename result<count_ints(CountT, T)>::type
|
||||
operator()(CountT const&, T const&) const
|
||||
{
|
||||
typedef typename result<count_ints(CountT, T)>::type result;
|
||||
return result();
|
||||
typedef typename result<count_ints(CountT, T)>::type result_;
|
||||
return result_();
|
||||
}
|
||||
};
|
||||
|
||||
|
212
test/algorithm/fold.hpp
Normal file
212
test/algorithm/fold.hpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2010 Christopher Schmidt
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/reverse.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/reverse_fold.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/iter_fold.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/reverse_iter_fold.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/mpl/transform.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/back.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/for_each.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/back_inserter.hpp>
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/copy.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace mpl=boost::mpl;
|
||||
namespace fusion=boost::fusion;
|
||||
|
||||
#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
|
||||
# ifdef BOOST_FUSION_TEST_ITER_FOLD
|
||||
# define BOOST_FUSION_TEST_FOLD_NAME reverse_iter_fold
|
||||
# else
|
||||
# define BOOST_FUSION_TEST_FOLD_NAME reverse_fold
|
||||
# endif
|
||||
#else
|
||||
# ifdef BOOST_FUSION_TEST_ITER_FOLD
|
||||
# define BOOST_FUSION_TEST_FOLD_NAME iter_fold
|
||||
# else
|
||||
# define BOOST_FUSION_TEST_FOLD_NAME fold
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct sum
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename Self, typename State, typename T>
|
||||
struct result<Self(State,T)>
|
||||
: fusion::result_of::make_pair<
|
||||
mpl::int_<
|
||||
boost::remove_reference<
|
||||
State
|
||||
>::type::first_type::value+1
|
||||
>
|
||||
, int
|
||||
>
|
||||
{
|
||||
BOOST_MPL_ASSERT((typename boost::is_reference<State>::type));
|
||||
BOOST_MPL_ASSERT((typename boost::is_reference<T>::type));
|
||||
};
|
||||
|
||||
#ifdef BOOST_FUSION_TEST_ITER_FOLD
|
||||
template<typename State, typename It>
|
||||
typename result<sum const&(State const&,It const&)>::type
|
||||
operator()(State const& state, It const& it)const
|
||||
{
|
||||
static const int n=State::first_type::value;
|
||||
return fusion::make_pair<mpl::int_<n+1> >(
|
||||
state.second+fusion::deref(it)*n);
|
||||
}
|
||||
#else
|
||||
template<typename State>
|
||||
typename result<sum const&(State const&, int const&)>::type
|
||||
operator()(State const& state, int const& e)const
|
||||
{
|
||||
static const int n=State::first_type::value;
|
||||
return fusion::make_pair<mpl::int_<n+1> >(state.second+e*n);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct meta_sum
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename Self, typename State, typename T>
|
||||
struct result<Self(State,T)>
|
||||
{
|
||||
BOOST_MPL_ASSERT((typename boost::is_reference<State>::type));
|
||||
BOOST_MPL_ASSERT((typename boost::is_reference<T>::type));
|
||||
|
||||
typedef typename boost::remove_reference<State>::type state;
|
||||
static const int n=mpl::front<state>::type::value;
|
||||
|
||||
#ifdef BOOST_FUSION_TEST_ITER_FOLD
|
||||
typedef typename
|
||||
fusion::result_of::value_of<
|
||||
typename boost::remove_reference<T>::type
|
||||
>::type
|
||||
t;
|
||||
#else
|
||||
typedef typename boost::remove_reference<T>::type t;
|
||||
#endif
|
||||
|
||||
typedef
|
||||
mpl::vector<
|
||||
mpl::int_<n+1>
|
||||
, mpl::int_<
|
||||
mpl::back<state>::type::value+t::value*n
|
||||
>
|
||||
>
|
||||
type;
|
||||
};
|
||||
|
||||
template<typename State, typename T>
|
||||
typename result<meta_sum const&(State const&,T const&)>::type
|
||||
operator()(State const&, T const&)const;
|
||||
};
|
||||
|
||||
struct fold_test_n
|
||||
{
|
||||
template<typename I>
|
||||
void
|
||||
operator()(I)const
|
||||
{
|
||||
static const int n=I::value;
|
||||
typedef mpl::range_c<int, 0, n> range;
|
||||
|
||||
static const int squares_sum=n*(n+1)*(2*n+1)/6;
|
||||
|
||||
{
|
||||
mpl::range_c<int, 1, n+1> init_range;
|
||||
typename fusion::result_of::as_vector<
|
||||
typename mpl::transform<
|
||||
range
|
||||
, mpl::always<int>
|
||||
, mpl::back_inserter<mpl::vector<> >
|
||||
>::type
|
||||
>::type vec(
|
||||
#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
|
||||
fusion::reverse(init_range)
|
||||
#else
|
||||
init_range
|
||||
#endif
|
||||
);
|
||||
|
||||
int result=BOOST_FUSION_TEST_FOLD_NAME(
|
||||
vec,
|
||||
fusion::make_pair<mpl::int_<1> >(0),
|
||||
sum()).second;
|
||||
std::cout << n << ": " << result << std::endl;
|
||||
BOOST_TEST(result==squares_sum);
|
||||
}
|
||||
|
||||
{
|
||||
typedef typename
|
||||
#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
|
||||
fusion::result_of::as_vector<
|
||||
typename mpl::copy<
|
||||
mpl::range_c<int, 1, n+1>
|
||||
, mpl::front_inserter<fusion::vector<> >
|
||||
>::type
|
||||
>::type
|
||||
#else
|
||||
fusion::result_of::as_vector<mpl::range_c<int, 1, n+1> >::type
|
||||
#endif
|
||||
vec;
|
||||
|
||||
typedef
|
||||
boost::is_same<
|
||||
typename fusion::result_of::BOOST_FUSION_TEST_FOLD_NAME<
|
||||
vec
|
||||
, mpl::vector<mpl::int_<1>, mpl::int_<0> >
|
||||
, meta_sum
|
||||
>::type
|
||||
, typename mpl::if_c<
|
||||
!n
|
||||
, mpl::vector<mpl::int_<1>, mpl::int_<0> > const&
|
||||
, mpl::vector<mpl::int_<n+1>, mpl::int_<squares_sum> >
|
||||
>::type
|
||||
>
|
||||
result_test;
|
||||
|
||||
BOOST_MPL_ASSERT((result_test));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
mpl::for_each<mpl::range_c<int, 0, 10> >(fold_test_n());
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#undef BOOST_FUSION_TEST_FOLD_NAME
|
||||
|
8
test/algorithm/fold2.cpp
Normal file
8
test/algorithm/fold2.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2010 Christopher Schmidt
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#include "fold.hpp"
|
10
test/algorithm/iter_fold.cpp
Normal file
10
test/algorithm/iter_fold.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2010 Christopher Schmidt
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#define BOOST_FUSION_TEST_ITER_FOLD
|
||||
#include "fold.hpp"
|
||||
#undef BOOST_FUSION_TEST_ITER_FOLD
|
@@ -16,8 +16,8 @@ namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
explicit search_for(int in_search)
|
||||
: search(in_search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
|
10
test/algorithm/reverse_fold.cpp
Normal file
10
test/algorithm/reverse_fold.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2010 Christopher Schmidt
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#define BOOST_FUSION_TEST_REVERSE_FOLD
|
||||
#include "fold.hpp"
|
||||
#undef BOOST_FUSION_TEST_REVERSE_FOLD
|
12
test/algorithm/reverse_iter_fold.cpp
Normal file
12
test/algorithm/reverse_iter_fold.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2010 Christopher Schmidt
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#define BOOST_FUSION_TEST_REVERSE_FOLD
|
||||
#define BOOST_FUSION_TEST_ITER_FOLD
|
||||
#include "fold.hpp"
|
||||
#undef BOOST_FUSION_TEST_ITER_FOLD
|
||||
#undef BOOST_FUSION_TEST_REVERSE_FOLD
|
@@ -1,124 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/generation/make_unfused_generic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
typedef mpl::true_ no_nullary_call;
|
||||
|
||||
using boost::ref;
|
||||
using boost::cref;
|
||||
|
||||
template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq &) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T const & elem, long value) const
|
||||
{
|
||||
return value + sizeof(T) * elem;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_unfused_generic< test_func<> >::type unfused_func =
|
||||
fusion::make_unfused_generic(f);
|
||||
|
||||
fusion::result_of::make_unfused_generic< boost::reference_wrapper<
|
||||
test_func<noncopyable> > >::type unfused_func_ref =
|
||||
fusion::make_unfused_generic(ref(f_nc));
|
||||
|
||||
fusion::result_of::make_unfused_generic< boost::reference_wrapper<
|
||||
test_func<noncopyable> const> >::type unfused_func_c_ref =
|
||||
fusion::make_unfused_generic(cref(f_nc));
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(const_(unfused_func)() == 0);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
long lvalue = 12;
|
||||
static const long expected = 1*sizeof(int) + 2*sizeof(long) + 7*sizeof(char);
|
||||
BOOST_TEST(unfused_func(lvalue,lvalue,1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 2*sizeof(long));
|
||||
BOOST_TEST(const_(unfused_func)(lvalue,lvalue,1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 4*sizeof(long));
|
||||
BOOST_TEST(unfused_func_ref(lvalue,lvalue,1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 6*sizeof(long));
|
||||
BOOST_TEST(unfused_func_c_ref(lvalue,lvalue,1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 8*sizeof(long));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,126 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/generation/make_unfused_lvalue_args.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
typedef mpl::true_ no_nullary_call;
|
||||
|
||||
using boost::ref;
|
||||
using boost::cref;
|
||||
|
||||
template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq &) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value + elem;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_unfused_lvalue_args< test_func<> >::type unfused_func =
|
||||
fusion::make_unfused_lvalue_args(f);
|
||||
|
||||
fusion::result_of::make_unfused_lvalue_args< boost::reference_wrapper<
|
||||
test_func<noncopyable> > >::type unfused_func_ref =
|
||||
fusion::make_unfused_lvalue_args(ref(f_nc));
|
||||
|
||||
fusion::result_of::make_unfused_lvalue_args< boost::reference_wrapper<
|
||||
test_func<noncopyable> const> >::type unfused_func_c_ref =
|
||||
fusion::make_unfused_lvalue_args(cref(f_nc));
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(const_(unfused_func)() == 0);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
long lv1 = 2; int lv2 = 3l; char lv3 = '\007';
|
||||
long expected;
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func(lv1,lv2,lv3) == 100 + expected);
|
||||
BOOST_TEST(lv1 == 2+1*sizeof(lv1) && lv2 == 3+1*sizeof(lv2) && lv3 == 7+1*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(const_(unfused_func)(lv1,lv2,lv3) == 0 + expected);
|
||||
BOOST_TEST(lv1 == 2+2*sizeof(lv1) && lv2 == 3+2*sizeof(lv2) && lv3 == 7+2*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_ref(lv1,lv2,lv3) == 100 + expected);
|
||||
BOOST_TEST(lv1 == 2+3*sizeof(lv1) && lv2 == 3+3*sizeof(lv2) && lv3 == 7+3*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_c_ref(lv1,lv2,lv3) == 0 + expected);
|
||||
BOOST_TEST(lv1 == 2+4*sizeof(lv1) && lv2 == 3+4*sizeof(lv2) && lv3 == 7+4*sizeof(lv3));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,110 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/generation/make_unfused_rvalue_args.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
typedef mpl::true_ no_nullary_call;
|
||||
|
||||
using boost::ref;
|
||||
using boost::cref;
|
||||
|
||||
template <class Base = boost::blank, class RemoveNullary = mpl::false_>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq &) >
|
||||
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
|
||||
boost::blank, mpl::identity<long> >::type
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T const & elem, long value) const
|
||||
{
|
||||
return value + sizeof(T) * elem;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_unfused_rvalue_args< test_func<> >::type unfused_func =
|
||||
fusion::make_unfused_rvalue_args(f);
|
||||
|
||||
fusion::result_of::make_unfused_rvalue_args< boost::reference_wrapper<
|
||||
test_func<noncopyable> > >::type unfused_func_ref =
|
||||
fusion::make_unfused_rvalue_args(ref(f_nc));
|
||||
|
||||
fusion::result_of::make_unfused_rvalue_args< boost::reference_wrapper<
|
||||
test_func<noncopyable> const> >::type unfused_func_c_ref =
|
||||
fusion::make_unfused_rvalue_args(cref(f_nc));
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(const_(unfused_func)() == 0);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
static const long expected = 1*sizeof(int) + 2*sizeof(long) + 7*sizeof(char);
|
||||
BOOST_TEST(unfused_func(1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(const_(unfused_func)(1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(unfused_func_ref(1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(unfused_func_c_ref(1,2l,'\007') == 0 + expected);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,126 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/adapter/unfused_generic.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
typedef mpl::true_ no_nullary_call;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self (Seq) >
|
||||
: mpl::identity<long>
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
template <typename T>
|
||||
long operator()(T const & elem, long value) const
|
||||
{
|
||||
return value + sizeof(T) * elem;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, typename T0, typename T1> struct result< Self(T0,T1) >
|
||||
: mpl::identity<long>
|
||||
{ };
|
||||
};
|
||||
};
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
typedef fusion::unfused_generic< test_func<> > t;
|
||||
BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
|
||||
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_generic< test_func<> > unfused_func;
|
||||
fusion::unfused_generic< test_func<noncopyable> & > unfused_func_ref(f);
|
||||
fusion::unfused_generic< test_func<> const > unfused_func_c;
|
||||
fusion::unfused_generic< test_func<> > const unfused_func_c2;
|
||||
fusion::unfused_generic< test_func<noncopyable> const & > unfused_func_c_ref(f);
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c() == 0);
|
||||
BOOST_TEST(unfused_func_c2() == 0);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
long lvalue = 12;
|
||||
// also test const lvalues to pick up compiler deficiencies in that area
|
||||
int const clvalue_1 = 1;
|
||||
long const clvalue_2 = 2;
|
||||
|
||||
static const long expected = 1*sizeof(int) + 2*sizeof(long) + 7*sizeof(char);
|
||||
BOOST_TEST(unfused_func(lvalue,lvalue,clvalue_1,clvalue_2,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 2*sizeof(long));
|
||||
BOOST_TEST(unfused_func_ref(lvalue,lvalue,1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 4*sizeof(long));
|
||||
BOOST_TEST(unfused_func_c(lvalue,lvalue,1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 6*sizeof(long));
|
||||
BOOST_TEST(unfused_func_c2(lvalue,lvalue,1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 8*sizeof(long));
|
||||
BOOST_TEST(unfused_func_c_ref(lvalue,lvalue,1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 12 + 10*sizeof(long));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,119 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/adapter/unfused_lvalue_args.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::identity<long>
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value + elem;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
typedef fusion::unfused_lvalue_args< test_func<> > t;
|
||||
BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
|
||||
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_lvalue_args< test_func<> > unfused_func;
|
||||
fusion::unfused_lvalue_args< test_func<noncopyable> & > unfused_func_ref(f);
|
||||
fusion::unfused_lvalue_args< test_func<> const > unfused_func_c;
|
||||
fusion::unfused_lvalue_args< test_func<> > const unfused_func_c2;
|
||||
fusion::unfused_lvalue_args< test_func<noncopyable> const & > unfused_func_c_ref(f);
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c() == 0);
|
||||
BOOST_TEST(unfused_func_c2() == 0);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
long lv1 = 2; int lv2 = 3l; char lv3 = '\007';
|
||||
long expected;
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func(lv1,lv2,lv3) == 100 + expected);
|
||||
BOOST_TEST(lv1 == 2+1*sizeof(lv1) && lv2 == 3+1*sizeof(lv2) && lv3 == 7+1*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_ref(lv1,lv2,lv3) == 100 + expected);
|
||||
BOOST_TEST(lv1 == 2+2*sizeof(lv1) && lv2 == 3+2*sizeof(lv2) && lv3 == 7+2*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_c(lv1,lv2,lv3) == 0 + expected);
|
||||
BOOST_TEST(lv1 == 2+3*sizeof(lv1) && lv2 == 3+3*sizeof(lv2) && lv3 == 7+3*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_c2(lv1,lv2,lv3) == 0 + expected);
|
||||
BOOST_TEST(lv1 == 2+4*sizeof(lv1) && lv2 == 3+4*sizeof(lv2) && lv3 == 7+4*sizeof(lv3));
|
||||
|
||||
expected = lv1+sizeof(lv1) + lv2+sizeof(lv2) + lv3+sizeof(lv3);
|
||||
BOOST_TEST(unfused_func_c_ref(lv1,lv2,lv3) == 0 + expected);
|
||||
BOOST_TEST(lv1 == 2+5*sizeof(lv1) && lv2 == 3+5*sizeof(lv2) && lv3 == 7+5*sizeof(lv3));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -1,102 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006-2007 Tobias Schwinger
|
||||
|
||||
Use modification and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
==============================================================================*/
|
||||
|
||||
#include <boost/fusion/functional/adapter/unfused_rvalue_args.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
using boost::noncopyable;
|
||||
typedef mpl::true_ no_nullary_call;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, class Seq>
|
||||
struct result< Self(Seq) >
|
||||
: mpl::identity<long>
|
||||
{ };
|
||||
|
||||
template <typename Seq>
|
||||
long operator()(Seq const & seq) const
|
||||
{
|
||||
long state = 0;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
template < typename Seq >
|
||||
long operator()(Seq const & seq)
|
||||
{
|
||||
long state = 100;
|
||||
return fusion::fold(seq, state, fold_op());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct fold_op
|
||||
{
|
||||
typedef long result_type;
|
||||
|
||||
template <typename T>
|
||||
long operator()(T const & elem, long value) const
|
||||
{
|
||||
return value + sizeof(T) * elem;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
typedef fusion::unfused_rvalue_args< test_func<> > t;
|
||||
BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
|
||||
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_rvalue_args< test_func<> > unfused_func;
|
||||
fusion::unfused_rvalue_args< test_func<noncopyable> & > unfused_func_ref(f);
|
||||
fusion::unfused_rvalue_args< test_func<> const > unfused_func_c;
|
||||
fusion::unfused_rvalue_args< test_func<> > const unfused_func_c2;
|
||||
fusion::unfused_rvalue_args< test_func<noncopyable> const & > unfused_func_c_ref(f);
|
||||
|
||||
BOOST_TEST(unfused_func() == 100);
|
||||
BOOST_TEST(unfused_func_ref() == 100);
|
||||
BOOST_TEST(unfused_func_c() == 0);
|
||||
BOOST_TEST(unfused_func_c2() == 0);
|
||||
BOOST_TEST(unfused_func_c_ref() == 0);
|
||||
|
||||
static const long expected = 1*sizeof(int) + 2*sizeof(long) + 7*sizeof(char);
|
||||
BOOST_TEST(unfused_func(1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(unfused_func_ref(1,2l,'\007') == 100 + expected);
|
||||
BOOST_TEST(unfused_func_c(1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(unfused_func_c2(1,2l,'\007') == 0 + expected);
|
||||
BOOST_TEST(unfused_func_c_ref(1,2l,'\007') == 0 + expected);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
|
@@ -31,7 +31,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(int x, int y) : x(x), y(y) {}
|
||||
point(int in_x, int in_y) : x(in_x), y(in_y) {}
|
||||
|
||||
int get_x() const { return x; }
|
||||
int get_y() const { return y; }
|
||||
@@ -98,14 +98,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p(5, 3);
|
||||
boost::fusion::vector<int, short> v(p);
|
||||
boost::fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p(5, 3);
|
||||
boost::fusion::list<int, short> l(p);
|
||||
boost::fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(int x, int y) : x(x), y(y) {}
|
||||
point(int in_x, int in_y) : x(in_x), y(in_y) {}
|
||||
|
||||
int get_x() const { return x; }
|
||||
int get_y() const { return y; }
|
||||
@@ -63,7 +63,7 @@ main()
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<adapted::point>));
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
|
||||
ns::point basep(123, 456);
|
||||
adapted::point p(basep);
|
||||
|
||||
@@ -102,7 +102,7 @@ main()
|
||||
// conversion from adapted::point to vector
|
||||
ns::point basep(5, 3);
|
||||
adapted::point p(basep);
|
||||
boost::fusion::vector<int, short> v(p);
|
||||
boost::fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ main()
|
||||
// conversion from adated::point to list
|
||||
ns::point basep(5, 3);
|
||||
adapted::point p(basep);
|
||||
boost::fusion::list<int, short> l(p);
|
||||
boost::fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -104,14 +104,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p = {5, 3};
|
||||
fusion::vector<int, short> v(p);
|
||||
fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p = {5, 3};
|
||||
fusion::list<int, short> l(p);
|
||||
fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ main()
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<adapted::point>));
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
|
||||
ns::point basep = {123, 456};
|
||||
adapted::point p(basep);
|
||||
|
||||
@@ -88,7 +88,7 @@ main()
|
||||
// conversion from adapted::point to vector
|
||||
ns::point basep = {5, 3};
|
||||
adapted::point p(basep);
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ main()
|
||||
// conversion from adapted::point to list
|
||||
ns::point basep = {5, 3};
|
||||
adapted::point p(basep);
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(X x, Y y) : x(x), y(y) {}
|
||||
point(X in_x, Y in_y) : x(in_x), y(in_y) {}
|
||||
|
||||
X get_x() const { return x; }
|
||||
Y get_y() const { return y; }
|
||||
@@ -102,14 +102,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p(5, 3);
|
||||
boost::fusion::vector<int, short> v(p);
|
||||
boost::fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p(5, 3);
|
||||
boost::fusion::list<int, short> l(p);
|
||||
boost::fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -102,14 +102,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p = {5, 3};
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p = {5, 3};
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(int x, int y) : x(x), y(y) {}
|
||||
point(int in_x, int in_y) : x(in_x), y(in_y) {}
|
||||
|
||||
int get_x() const { return x; }
|
||||
int get_y() const { return y; }
|
||||
@@ -106,14 +106,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p(5, 3);
|
||||
fusion::vector<int, short> v(p);
|
||||
fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p(5, 3);
|
||||
fusion::list<int, short> l(p);
|
||||
fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(int x, int y) : x(x), y(y) {}
|
||||
point(int in_x, int in_y) : x(in_x), y(in_y) {}
|
||||
|
||||
int get_x() const { return x; }
|
||||
int get_y() const { return y; }
|
||||
@@ -71,7 +71,7 @@ main()
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<adapted::point>));
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
|
||||
ns::point basep(123, 456);
|
||||
adapted::point p(basep);
|
||||
|
||||
@@ -112,7 +112,7 @@ main()
|
||||
ns::point basep(5, 3);
|
||||
adapted::point p(basep);
|
||||
|
||||
fusion::vector<int, short> v(p);
|
||||
fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ main()
|
||||
ns::point basep(5, 3);
|
||||
adapted::point p(basep);
|
||||
|
||||
fusion::list<int, short> l(p);
|
||||
fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -97,14 +97,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p = {5, 3};
|
||||
fusion::vector<int, short> v(p);
|
||||
fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p = {5, 3};
|
||||
fusion::list<int, short> l(p);
|
||||
fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -63,7 +63,7 @@ main()
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<adapted::point>));
|
||||
BOOST_MPL_ASSERT((traits::is_view<adapted::point>));
|
||||
ns::point basep = {123, 456};
|
||||
adapted::point p(basep);
|
||||
|
||||
@@ -103,7 +103,7 @@ main()
|
||||
// conversion from adapted::point to vector
|
||||
ns::point basep = {5, 3};
|
||||
adapted::point p(basep);
|
||||
fusion::vector<int, short> v(p);
|
||||
fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ main()
|
||||
// conversion from adapted::point to list
|
||||
ns::point basep = {5, 3};
|
||||
adapted::point p(basep);
|
||||
fusion::list<int, short> l(p);
|
||||
fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ namespace ns
|
||||
public:
|
||||
|
||||
point() : x(0), y(0) {}
|
||||
point(X x, Y y) : x(x), y(y) {}
|
||||
point(X x_, Y y_) : x(x_), y(y_) {}
|
||||
|
||||
X get_x() const { return x; }
|
||||
Y get_y() const { return y; }
|
||||
@@ -110,14 +110,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p(5, 3);
|
||||
boost::fusion::vector<int, short> v(p);
|
||||
boost::fusion::vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p(5, 3);
|
||||
boost::fusion::list<int, short> l(p);
|
||||
boost::fusion::list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -97,14 +97,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p = {5, 3};
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p = {5, 3};
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::is_same;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
@@ -39,18 +40,18 @@ main()
|
||||
make_cons(1, make_cons(hello));
|
||||
|
||||
BOOST_TEST((*begin(ns) == 1));
|
||||
BOOST_TEST((*next(begin(ns)) == hello));
|
||||
BOOST_TEST((*fusion::next(begin(ns)) == hello));
|
||||
|
||||
*begin(ns) += 1;
|
||||
*next(begin(ns)) += ' ';
|
||||
*fusion::next(begin(ns)) += ' ';
|
||||
|
||||
BOOST_TEST((*begin(ns) == 2));
|
||||
BOOST_TEST((*next(begin(ns)) == hello + ' '));
|
||||
BOOST_TEST((*fusion::next(begin(ns)) == hello + ' '));
|
||||
|
||||
for_each(ns, boost::lambda::_1 += ' ');
|
||||
|
||||
BOOST_TEST((*begin(ns) == 2 + ' '));
|
||||
BOOST_TEST((*next(begin(ns)) == hello + ' ' + ' '));
|
||||
BOOST_TEST((*fusion::next(begin(ns)) == hello + ' ' + ' '));
|
||||
}
|
||||
|
||||
{
|
||||
|
@@ -75,14 +75,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p(5, 3);
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p(5, 3);
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -79,14 +79,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p(5, 3);
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p(5, 3);
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -72,14 +72,14 @@ main()
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p(5, 3);
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p(5, 3);
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -75,14 +75,14 @@ main()
|
||||
{
|
||||
// conversion from point to vector
|
||||
point p(5, 3);
|
||||
vector<int, short> v(p);
|
||||
vector<int, long> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from point to list
|
||||
point p(5, 3);
|
||||
list<int, short> l(p);
|
||||
list<int, long> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,9 @@ main()
|
||||
BOOST_STATIC_ASSERT(result_of::size<filter_view_type>::value == 4);
|
||||
}
|
||||
|
||||
{
|
||||
//cschmidt: This is illegal C++. ADL instantiates less<_, int_<3> > - which
|
||||
//leads to compile errors.
|
||||
/*{
|
||||
// $$$ JDG $$$ For some obscure reason, EDG based compilers
|
||||
// (e.g. comeau 4.3.3, intel) have problems with this.
|
||||
// vc7.1 and g++ are ok. The errors from comeau are useless.
|
||||
@@ -94,7 +96,7 @@ main()
|
||||
BOOST_TEST((view == make_vector(1, 2, 0, -1)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<filter_view_type>::value == 4);
|
||||
#endif
|
||||
}
|
||||
}*/
|
||||
|
||||
{
|
||||
// Previous filtering out all values caused problems as begin<seq> was not equal to end<seq>
|
||||
|
@@ -28,6 +28,7 @@ int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
@@ -104,9 +105,9 @@ main()
|
||||
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of_data<result_of::next<result_of::begin<range_type>::type>::type>::type, char>));
|
||||
|
||||
std::cout << deref_data(begin(r)) << std::endl;
|
||||
std::cout << deref_data(next(begin(r))) << std::endl;
|
||||
std::cout << deref_data(fusion::next(begin(r))) << std::endl;
|
||||
BOOST_TEST((deref_data(begin(r)) == "foo"));
|
||||
BOOST_TEST((deref_data(next(begin(r))) == 'x'));
|
||||
BOOST_TEST((deref_data(fusion::next(begin(r))) == 'x'));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
@@ -34,6 +34,7 @@ int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
@@ -175,11 +176,11 @@ main()
|
||||
, float>));
|
||||
|
||||
std::cout << deref_data(begin(j)) << std::endl;
|
||||
std::cout << deref_data(boost::fusion::next(begin(j))) << std::endl;
|
||||
std::cout << deref_data(next(boost::fusion::next(begin(j)))) << std::endl;
|
||||
std::cout << deref_data(fusion::next(begin(j))) << std::endl;
|
||||
std::cout << deref_data(fusion::next(fusion::next(begin(j)))) << std::endl;
|
||||
BOOST_TEST((deref_data(begin(j)) == 0));
|
||||
BOOST_TEST((deref_data(boost::fusion::next(begin(j))) == "foo"));
|
||||
BOOST_TEST((deref_data(next(boost::fusion::next(begin(j)))) == 1.3f));
|
||||
BOOST_TEST((deref_data(fusion::next(begin(j))) == "foo"));
|
||||
BOOST_TEST((deref_data(fusion::next(fusion::next(begin(j)))) == 1.3f));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
@@ -29,6 +29,7 @@ main()
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::fusion::pair;
|
||||
using boost::fusion::make_pair;
|
||||
|
||||
@@ -66,15 +67,15 @@ main()
|
||||
BOOST_STATIC_ASSERT((!result_of::has_key<map_type, std::string>::value));
|
||||
|
||||
std::cout << deref_data(begin(m)) << std::endl;
|
||||
std::cout << deref_data(next(begin(m))) << std::endl;
|
||||
std::cout << deref_data(fusion::next(begin(m))) << std::endl;
|
||||
|
||||
BOOST_TEST(deref_data(begin(m)) == 'X');
|
||||
BOOST_TEST(deref_data(next(begin(m))) == "Men");
|
||||
BOOST_TEST(deref_data(fusion::next(begin(m))) == "Men");
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::begin<map_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::next<result_of::begin<map_type>::type>::type>::type, double>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::begin<map_type>::type>::type, char>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::next<result_of::begin<map_type>::type>::type>::type, std::string>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::key_of<result_of::begin<map_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::key_of<result_of::next<result_of::begin<map_type>::type>::type>::type, double>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::value_of_data<result_of::begin<map_type>::type>::type, char>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::value_of_data<result_of::next<result_of::begin<map_type>::type>::type>::type, std::string>::value));
|
||||
}
|
||||
|
||||
{
|
||||
|
@@ -151,7 +151,7 @@ test()
|
||||
{ // testing front & back
|
||||
|
||||
typedef FUSION_SEQUENCE<int, float, std::string> tup;
|
||||
tup t(1, 2.2, "Kimpo");
|
||||
tup t(1, 2.2f, "Kimpo");
|
||||
|
||||
BOOST_TEST(front(t) == 1);
|
||||
#if !defined(FUSION_FORWARD_ONLY) // list has no back
|
||||
|
@@ -26,7 +26,7 @@ BOOST_FUSION_ADAPT_STRUCT(
|
||||
(int, int_)
|
||||
(std::string, string_)
|
||||
(double, double_)
|
||||
);
|
||||
)
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
|
@@ -29,6 +29,7 @@ main()
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::fusion::pair;
|
||||
using boost::fusion::make_pair;
|
||||
|
||||
@@ -61,15 +62,15 @@ main()
|
||||
BOOST_STATIC_ASSERT((!result_of::has_key<set_type, double>::value));
|
||||
|
||||
std::cout << deref_data(begin(m)) << std::endl;
|
||||
std::cout << deref_data(next(begin(m))) << std::endl;
|
||||
std::cout << deref_data(fusion::next(begin(m))) << std::endl;
|
||||
|
||||
BOOST_TEST(deref_data(begin(m)) == 123);
|
||||
BOOST_TEST(deref_data(next(begin(m))) == "Hola");
|
||||
BOOST_TEST(deref_data(fusion::next(begin(m))) == "Hola");
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::begin<set_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::key_of<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::begin<set_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of_data<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::key_of<result_of::begin<set_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::key_of<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::value_of_data<result_of::begin<set_type>::type>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<result_of::value_of_data<result_of::next<result_of::begin<set_type>::type>::type>::type, std::string>::value));
|
||||
}
|
||||
|
||||
{
|
||||
|
@@ -48,7 +48,7 @@ namespace Core
|
||||
} // namespace Core
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main()
|
||||
{
|
||||
std::tr1::tuple<int, int, int, int> test = Core::Demo();
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user