forked from boostorg/fusion
Quickbook: Copy trunk libs into quickbook-dev branch.
[SVN r75213]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
Copyright (c) Dan Marsden
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
@@ -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")));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/pop_back.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/include/back.hpp>
|
||||
#include <boost/fusion/include/array.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
@@ -41,6 +48,57 @@ main()
|
||||
BOOST_TEST((boost::fusion::pop_back(mpl_vec()) == make_vector(1, 2, 3, 4)));
|
||||
}
|
||||
|
||||
{
|
||||
list<int, int> l(1, 2);
|
||||
std::cout << pop_back(l) << std::endl;
|
||||
BOOST_TEST((pop_back(l) == make_list(1)));
|
||||
}
|
||||
|
||||
{ // make sure empty sequences are OK
|
||||
list<int> l(1);
|
||||
std::cout << pop_back(l) << std::endl;
|
||||
BOOST_TEST((pop_back(l) == make_list()));
|
||||
}
|
||||
|
||||
{
|
||||
single_view<int> sv(1);
|
||||
std::cout << pop_back(sv) << std::endl;
|
||||
|
||||
// Compile check only
|
||||
begin(pop_back(sv)) == end(sv);
|
||||
end(pop_back(sv)) == begin(sv);
|
||||
}
|
||||
|
||||
// $$$ JDG: TODO add compile fail facility $$$
|
||||
//~ { // compile fail check (Disabled for now)
|
||||
//~ list<> l;
|
||||
//~ std::cout << pop_back(l) << std::endl;
|
||||
//~ }
|
||||
|
||||
#ifndef BOOST_NO_AUTO_DECLARATIONS
|
||||
{
|
||||
auto vec = make_vector(1, 3.14, "hello");
|
||||
|
||||
// Compile check only
|
||||
auto popv = pop_back(vec);
|
||||
std::cout << popv << std::endl;
|
||||
|
||||
auto push = push_back(vec, 42);
|
||||
auto pop = pop_back(vec);
|
||||
auto i1 = find<int>(popv);
|
||||
auto i2 = find<double>(pop);
|
||||
|
||||
BOOST_TEST(i1 != end(pop));
|
||||
BOOST_TEST(i2 != end(pop));
|
||||
BOOST_TEST(i1 != i2);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
boost::array<std::size_t, 2> a = { 10, 50 };
|
||||
BOOST_TEST(back(pop_back(a)) == 10);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
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)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2011 Eric Niebler
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct not_there {};
|
||||
|
||||
template<typename Tree>
|
||||
void
|
||||
process_tree(Tree const &tree)
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef typename boost::fusion::result_of::find<Tree const, short>::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find<Tree const, float>::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find<Tree const, not_there>::type not_there_iter;
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = fusion::find<short>(tree);
|
||||
float_iter fi = fusion::find<float>(tree);
|
||||
|
||||
// they behave like ordinary Fusion iterators ...
|
||||
BOOST_TEST((*si == short('d')));
|
||||
BOOST_TEST((*fi == float(1)));
|
||||
|
||||
// Searching for something that's not there should return the end iterator.
|
||||
not_there_iter nti = fusion::find<not_there>(tree);
|
||||
BOOST_TEST((nti == fusion::end(tree)));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
process_tree(
|
||||
make_tree(
|
||||
make_vector(double(0),'B')
|
||||
, make_tree(
|
||||
make_vector(1,2,long(3))
|
||||
, make_tree(make_vector('a','b','c'))
|
||||
, make_tree(make_vector(short('d'),'e','f'))
|
||||
)
|
||||
, make_tree(
|
||||
make_vector(4,5,6)
|
||||
, make_tree(make_vector(float(1),'h','i'))
|
||||
, make_tree(make_vector('j','k','l'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2011 Eric Niebler
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct not_there {};
|
||||
|
||||
template<typename Tree>
|
||||
void
|
||||
process_tree(Tree const &tree)
|
||||
{
|
||||
using namespace boost;
|
||||
using mpl::_;
|
||||
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,not_there> >::type not_there_iter;
|
||||
|
||||
// find_if of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = fusion::find_if<is_same<_,short> >(tree);
|
||||
float_iter fi = fusion::find_if<is_same<_,float> >(tree);
|
||||
|
||||
// they behave like ordinary Fusion iterators ...
|
||||
BOOST_TEST((*si == short('d')));
|
||||
BOOST_TEST((*fi == float(1)));
|
||||
|
||||
// Searching for something that's not there should return the end iterator.
|
||||
not_there_iter nti = fusion::find_if<is_same<_,not_there> >(tree);
|
||||
BOOST_TEST((nti == fusion::end(tree)));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
process_tree(
|
||||
make_tree(
|
||||
make_vector(double(0),'B')
|
||||
, make_tree(
|
||||
make_vector(1,2,long(3))
|
||||
, make_tree(make_vector('a','b','c'))
|
||||
, make_tree(make_vector(short('d'),'e','f'))
|
||||
)
|
||||
, make_tree(
|
||||
make_vector(4,5,6)
|
||||
, make_tree(make_vector(float(1),'h','i'))
|
||||
, make_tree(make_vector('j','k','l'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2011 Eric Niebler
|
||||
|
||||
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 <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct write_string
|
||||
{
|
||||
typedef std::ostream* result_type;
|
||||
|
||||
template<typename T>
|
||||
std::ostream* operator()(std::ostream* sout, T const& t) const
|
||||
{
|
||||
return &(*sout << t << " ");
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Tree>
|
||||
void
|
||||
process_tree(Tree const &tree)
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
std::stringstream str;
|
||||
fusion::fold(tree, &str, write_string());
|
||||
std::string res = str.str();
|
||||
|
||||
BOOST_TEST_EQ(res, "a b c 1 2 3 100 e f 0 B 1 h i 4 5 6 j k l ");
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
process_tree(
|
||||
make_tree(
|
||||
make_vector(double(0),'B')
|
||||
, make_tree(
|
||||
make_vector(1,2,long(3))
|
||||
, make_tree(make_vector('a','b','c'))
|
||||
, make_tree(make_vector(short('d'),'e','f'))
|
||||
)
|
||||
, make_tree(
|
||||
make_vector(4,5,6)
|
||||
, make_tree(make_vector(float(1),'h','i'))
|
||||
, make_tree(make_vector('j','k','l'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2011 Eric Niebler
|
||||
|
||||
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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct print
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T const& v) const
|
||||
{
|
||||
std::cout << "[ " << v << " ] ";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
for_each(
|
||||
make_tree(
|
||||
make_vector(double(0),'B')
|
||||
, make_tree(
|
||||
make_vector(1,2,long(3))
|
||||
, make_tree(make_vector('a','b','c'))
|
||||
, make_tree(make_vector(short('d'),'e','f'))
|
||||
)
|
||||
, make_tree(
|
||||
make_vector(4,5,6)
|
||||
, make_tree(make_vector(float(1),'h','i'))
|
||||
, make_tree(make_vector('j','k','l'))
|
||||
)
|
||||
)
|
||||
, print()
|
||||
);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
Reference in New Issue
Block a user