baking segmented Fusion

[SVN r73854]
This commit is contained in:
Eric Niebler
2011-08-17 18:53:56 +00:00
parent 2baebc560a
commit 528ad04fdb
86 changed files with 1403 additions and 1041 deletions

View File

@ -30,7 +30,7 @@ void test_set(Set const& set)
using namespace boost::fusion;
std::cout << set << std::endl;
BOOST_STATIC_ASSERT(result_of::size<Set>::value == 3);
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Set>::value == 3);
BOOST_TEST((*find<int>(set) == 1));
BOOST_TEST((*find<double>(set) == 1.5));
BOOST_TEST((*find<std::string>(set) == "hello"));
@ -47,7 +47,7 @@ void test_map(Map const& map)
using namespace boost::fusion;
std::cout << map << std::endl;
BOOST_STATIC_ASSERT(result_of::size<Map>::value == 3);
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Map>::value == 3);
BOOST_TEST(((*find<_1>(map)).second == 1));
BOOST_TEST(((*find<_3>(map)).second == 1.5));
BOOST_TEST(((*find<_4>(map)).second == std::string("hello")));

View File

@ -59,7 +59,7 @@ struct sum
template<typename Self, typename State, typename T>
struct result<Self(State,T)>
: fusion::result_of::make_pair<
: boost::fusion::result_of::make_pair<
mpl::int_<
boost::remove_reference<
State
@ -108,7 +108,7 @@ struct meta_sum
#ifdef BOOST_FUSION_TEST_ITER_FOLD
typedef typename
fusion::result_of::value_of<
boost::fusion::result_of::value_of<
typename boost::remove_reference<T>::type
>::type
t;
@ -144,7 +144,7 @@ struct fold_test_n
{
mpl::range_c<int, 1, n+1> init_range;
typename fusion::result_of::as_vector<
typename boost::fusion::result_of::as_vector<
typename mpl::transform<
range
, mpl::always<int>
@ -169,20 +169,20 @@ struct fold_test_n
{
typedef typename
#ifdef BOOST_FUSION_TEST_REVERSE_FOLD
fusion::result_of::as_vector<
boost::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
boost::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<
typename boost::fusion::result_of::BOOST_FUSION_TEST_FOLD_NAME<
vec
, mpl::vector<mpl::int_<1>, mpl::int_<0> >
, meta_sum

View File

@ -19,9 +19,9 @@ process_tree(Tree const &tree)
{
using namespace boost;
typedef typename fusion::result_of::find_s<Tree const, short>::type short_iter;
typedef typename fusion::result_of::find_s<Tree const, float>::type float_iter;
typedef typename fusion::result_of::find_s<Tree const, not_there>::type not_there_iter;
typedef typename boost::fusion::result_of::find_s<Tree const, short>::type short_iter;
typedef typename boost::fusion::result_of::find_s<Tree const, float>::type float_iter;
typedef typename boost::fusion::result_of::find_s<Tree const, not_there>::type not_there_iter;
// find_if_s of a segmented data structure returns generic
// segmented iterators

View File

@ -22,9 +22,9 @@ process_tree(Tree const &tree)
using namespace boost;
using mpl::_;
typedef typename fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
typedef typename fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
typedef typename fusion::result_of::find_if_s<Tree const, is_same<_,not_there> >::type not_there_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,not_there> >::type not_there_iter;
// find_if_s of a segmented data structure returns generic
// segmented iterators

View File

@ -109,46 +109,46 @@ main()
{
typedef range_c<int, 5, 9> sequence_type;
sequence_type sequence;
std::cout << transform(sequence, square()) << std::endl;
BOOST_TEST((transform(sequence, square()) == make_vector(25, 36, 49, 64)));
std::cout << boost::fusion::transform(sequence, square()) << std::endl;
BOOST_TEST((boost::fusion::transform(sequence, square()) == make_vector(25, 36, 49, 64)));
}
{
typedef range_c<int, 5, 9> mpl_list1;
std::cout << transform(mpl_list1(), square()) << std::endl;
BOOST_TEST((transform(mpl_list1(), square()) == make_vector(25, 36, 49, 64)));
std::cout << boost::fusion::transform(mpl_list1(), square()) << std::endl;
BOOST_TEST((boost::fusion::transform(mpl_list1(), square()) == make_vector(25, 36, 49, 64)));
}
{
vector<int, int, int> tup(1, 2, 3);
std::cout << transform(tup, square()) << std::endl;
BOOST_TEST((transform(tup, square()) == make_vector(1, 4, 9)));
std::cout << boost::fusion::transform(tup, square()) << std::endl;
BOOST_TEST((boost::fusion::transform(tup, square()) == make_vector(1, 4, 9)));
}
{
vector<int, int, int> tup1(1, 2, 3);
vector<int, int, int> tup2(4, 5, 6);
std::cout << transform(tup1, tup2, add()) << std::endl;
BOOST_TEST((transform(tup1, tup2, add()) == make_vector(5, 7, 9)));
std::cout << boost::fusion::transform(tup1, tup2, add()) << std::endl;
BOOST_TEST((boost::fusion::transform(tup1, tup2, add()) == make_vector(5, 7, 9)));
}
{
// Unary transform that requires lvalues, just check compilation
vector<int, int, int> tup1(1, 2, 3);
BOOST_TEST(at_c<0>(transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(*begin(transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(at_c<0>(boost::fusion::transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(*begin(boost::fusion::transform(tup1, unary_lvalue_transform())) == &at_c<0>(tup1));
}
{
vector<int, int, int> tup1(1, 2, 3);
vector<int, int, int> tup2(4, 5, 6);
BOOST_TEST(at_c<0>(transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(*begin(transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(at_c<0>(boost::fusion::transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
BOOST_TEST(*begin(boost::fusion::transform(tup1, tup2, binary_lvalue_transform())) == &at_c<0>(tup1));
}
{
vector<int, int, int> tup1(1, 2, 3);
BOOST_TEST(transform(tup1, twice) == make_vector(2,4,6));
BOOST_TEST(boost::fusion::transform(tup1, twice) == make_vector(2,4,6));
}