mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
This commit is contained in:
147
test/Jamfile
147
test/Jamfile
@ -1,147 +0,0 @@
|
||||
##==============================================================================
|
||||
# Copyright (c) 2003-2006 Joel de Guzman
|
||||
#
|
||||
# Use, modification and distribution is 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)
|
||||
#==============================================================================
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
{
|
||||
test-suite fusion :
|
||||
|
||||
[ run algorithm/all.cpp : : : : ]
|
||||
[ run algorithm/any.cpp : : : : ]
|
||||
[ run algorithm/clear.cpp : : : : ]
|
||||
[ run algorithm/count.cpp : : : : ]
|
||||
[ run algorithm/count_if.cpp : : : : ]
|
||||
[ run algorithm/erase.cpp : : : : ]
|
||||
[ run algorithm/erase_key.cpp : : : : ]
|
||||
[ run algorithm/filter.cpp : : : : ]
|
||||
[ run algorithm/filter_if.cpp : : : : ]
|
||||
[ run algorithm/find.cpp : : : : ]
|
||||
[ run algorithm/find_if.cpp : : : : ]
|
||||
[ run algorithm/fold.cpp : : : : ]
|
||||
[ run algorithm/for_each.cpp : : : : ]
|
||||
[ run algorithm/insert.cpp : : : : ]
|
||||
[ run algorithm/insert_range.cpp : : : : ]
|
||||
[ run algorithm/none.cpp : : : : ]
|
||||
[ run algorithm/pop_back.cpp : : : : ]
|
||||
[ run algorithm/pop_front.cpp : : : : ]
|
||||
[ run algorithm/push_back.cpp : : : : ]
|
||||
[ run algorithm/push_front.cpp : : : : ]
|
||||
[ run algorithm/remove.cpp : : : : ]
|
||||
[ run algorithm/remove_if.cpp : : : : ]
|
||||
[ run algorithm/replace.cpp : : : : ]
|
||||
[ run algorithm/replace_if.cpp : : : : ]
|
||||
[ run algorithm/reverse.cpp : : : : ]
|
||||
[ run algorithm/transform.cpp : : : : ]
|
||||
[ run algorithm/join.cpp : : : : ]
|
||||
[ run algorithm/zip.cpp : : : : ]
|
||||
[ run algorithm/zip2.cpp : : : : ]
|
||||
[ run algorithm/zip_ignore.cpp : : : : ]
|
||||
|
||||
[ run sequence/as_list.cpp : : : : ]
|
||||
[ run sequence/as_map.cpp : : : : ]
|
||||
[ run sequence/as_set.cpp : : : : ]
|
||||
[ run sequence/as_vector.cpp : : : : ]
|
||||
[ run sequence/boost_tuple.cpp : : : : ]
|
||||
[ run sequence/cons.cpp : : : : ]
|
||||
[ run sequence/filter_view.cpp : : : : ]
|
||||
[ run sequence/io.cpp : : : : ]
|
||||
[ run sequence/iterator_range.cpp : : : : ]
|
||||
[ run sequence/joint_view.cpp : : : : ]
|
||||
[ run sequence/list_comparison.cpp : : : : ]
|
||||
[ run sequence/list_construction.cpp : : : : ]
|
||||
[ run sequence/list_copy.cpp : : : : ]
|
||||
[ run sequence/list_iterator.cpp : : : : ]
|
||||
[ run sequence/list_make.cpp : : : : ]
|
||||
[ run sequence/list_misc.cpp : : : : ]
|
||||
[ run sequence/list_mutate.cpp : : : : ]
|
||||
[ run sequence/list_tie.cpp : : : : ]
|
||||
[ run sequence/list_value_at.cpp : : : : ]
|
||||
[ run sequence/deque_comparison.cpp : : : : ]
|
||||
[ run sequence/deque_construction.cpp : : : : ]
|
||||
[ run sequence/deque_copy.cpp : : : : ]
|
||||
[ run sequence/deque_iterator.cpp : : : : ]
|
||||
[ run sequence/deque_make.cpp : : : : ]
|
||||
[ run sequence/deque_misc.cpp : : : : ]
|
||||
[ run sequence/deque_mutate.cpp : : : : ]
|
||||
[ run sequence/deque_tie.cpp : : : : ]
|
||||
[ run sequence/deque_value_at.cpp : : : : ]
|
||||
[ run sequence/front_extended_deque.cpp : : : : ]
|
||||
[ run sequence/back_extended_deque.cpp : : : : ]
|
||||
[ run sequence/make_list.cpp : : : : ]
|
||||
[ run sequence/make_vector.cpp : : : : ]
|
||||
[ run sequence/map.cpp : : : : ]
|
||||
[ run sequence/map_tie.cpp : : : : ]
|
||||
[ run sequence/reverse_view.cpp : : : : ]
|
||||
[ run sequence/set.cpp : : : : ]
|
||||
[ run sequence/single_view.cpp : : : : ]
|
||||
[ run sequence/std_pair.cpp : : : : ]
|
||||
[ run sequence/array.cpp : : : : ]
|
||||
[ run sequence/variant.cpp : : : : ]
|
||||
[ run sequence/tuple_comparison.cpp : : : : ]
|
||||
[ run sequence/tuple_construction.cpp : : : : ]
|
||||
[ run sequence/tuple_copy.cpp : : : : ]
|
||||
[ run sequence/tuple_element.cpp : : : : ]
|
||||
[ run sequence/tuple_make.cpp : : : : ]
|
||||
[ run sequence/tuple_misc.cpp : : : : ]
|
||||
[ run sequence/tuple_mutate.cpp : : : : ]
|
||||
[ run sequence/tuple_tie.cpp : : : : ]
|
||||
[ run sequence/transform_view.cpp : : : : ]
|
||||
[ run sequence/vector_comparison.cpp : : : : ]
|
||||
[ run sequence/vector_construction.cpp : : : : ]
|
||||
[ run sequence/vector_copy.cpp : : : : ]
|
||||
[ run sequence/vector_iterator.cpp : : : : ]
|
||||
[ run sequence/vector_make.cpp : : : : ]
|
||||
[ run sequence/vector_misc.cpp : : : : ]
|
||||
[ run sequence/vector_mutate.cpp : : : : ]
|
||||
[ run sequence/vector_n.cpp : : : : ]
|
||||
[ run sequence/vector_tie.cpp : : : : ]
|
||||
[ run sequence/vector_value_at.cpp : : : : ]
|
||||
[ run sequence/zip_view.cpp : : : : ]
|
||||
[ run sequence/zip_view2.cpp : : : : ]
|
||||
[ run sequence/zip_view_ignore.cpp : : : : ]
|
||||
[ run sequence/repetitive_view.cpp : : : : ]
|
||||
[ run sequence/deduce_sequence.cpp : : : : ]
|
||||
[ run sequence/adapt_struct.cpp : : : : ]
|
||||
[ run sequence/adapt_assoc_struct.cpp : : : : ]
|
||||
|
||||
[ run functional/fused.cpp : : : : ]
|
||||
[ run functional/fused_function_object.cpp : : : : ]
|
||||
[ run functional/fused_procedure.cpp : : : : ]
|
||||
[ run functional/unfused_generic.cpp : : : : ]
|
||||
[ run functional/unfused_lvalue_args.cpp : : : : ]
|
||||
[ run functional/unfused_rvalue_args.cpp : : : : ]
|
||||
[ run functional/unfused_typed.cpp : : : : ]
|
||||
[ run functional/make_fused.cpp : : : : ]
|
||||
[ run functional/make_fused_function_object.cpp : : : : ]
|
||||
[ run functional/make_fused_procedure.cpp : : : : ]
|
||||
[ run functional/make_unfused_generic.cpp : : : : ]
|
||||
[ run functional/make_unfused_lvalue_args.cpp : : : : ]
|
||||
[ run functional/make_unfused_rvalue_args.cpp : : : : ]
|
||||
[ run functional/invoke.cpp : : : : ]
|
||||
[ run functional/invoke_function_object.cpp : : : : ]
|
||||
[ run functional/invoke_procedure.cpp : : : : ]
|
||||
[ run sequence/swap.cpp : : : : ]
|
||||
|
||||
# [ compile-fail xxx.cpp : : : : ]
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
{
|
||||
# Text for extension features, must be explicitly specified on the command line to be run
|
||||
# TODO these are not in a test-suite because currently test-suites cannot be marked "explicit"
|
||||
|
||||
run algorithm/ext_/for_each_s.cpp ;
|
||||
explicit for_each_s ;
|
||||
|
||||
run algorithm/ext_/find_if_s.cpp ;
|
||||
explicit find_if_s ;
|
||||
|
||||
run sequence/ext_/iterator_range_s.cpp ;
|
||||
explicit iterator_range_s ;
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/algorithm/query/all.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
bool operator()(T const& v) const
|
||||
{
|
||||
return v == search;
|
||||
}
|
||||
|
||||
int search;
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
|
||||
BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 == 1)));
|
||||
BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 < 3)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1> mpl_vec;
|
||||
// We cannot use lambda here as mpl vec iterators return
|
||||
// rvalues, and lambda needs lvalues.
|
||||
BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1)));
|
||||
BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
Copyright (c) Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/algorithm/query/any.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
bool operator()(T const& v) const
|
||||
{
|
||||
return v == search;
|
||||
}
|
||||
|
||||
int search;
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST(boost::fusion::any(t, boost::lambda::_1 == 2));
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
|
||||
// We cannot use lambda here as mpl vec iterators return
|
||||
// rvalues, and lambda needs lvalues.
|
||||
BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2)));
|
||||
BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/clear.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing pop_back
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << clear(t1) << std::endl;
|
||||
BOOST_TEST((clear(t1) == make_vector()));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
std::cout << boost::fusion::clear(mpl_vec()) << std::endl;
|
||||
BOOST_TEST((boost::fusion::clear(mpl_vec()) == make_vector()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005 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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/algorithm/query/count.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 1, 1);
|
||||
BOOST_TEST(boost::fusion::count(t, 1) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST(boost::fusion::count(t, 3) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, std::string, double> t(4, "hello", 4);
|
||||
BOOST_TEST(boost::fusion::count(t, "hello") == 1);
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 2, 2, 3, 3> mpl_vec;
|
||||
BOOST_TEST(boost::fusion::count(mpl_vec(), 2) == 3);
|
||||
BOOST_TEST(boost::fusion::count(mpl_vec(), 3) == 2);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005 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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/algorithm/query/count_if.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <functional>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 2) == 1);
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 3) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
|
||||
// Cannot use lambda here as mpl iterators return rvalues and lambda needs lvalues
|
||||
BOOST_TEST(boost::fusion::count_if(mpl_vec(), std::bind2nd(std::less_equal<int>(), 2)) == 2);
|
||||
BOOST_TEST(boost::fusion::count_if(mpl_vec(), std::bind2nd(std::greater<int>(), 2)) == 1);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/vector/vector_iterator.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/algorithm/transformation/erase.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/advance.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::begin;
|
||||
using boost::mpl::advance;
|
||||
using boost::mpl::int_;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing erase
|
||||
|
||||
{
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, "Ruby");
|
||||
vector_iterator<vector_type, 2> pos(t1);
|
||||
|
||||
std::cout << erase(t1, pos) << std::endl;
|
||||
BOOST_TEST((erase(t1, pos) == make_vector(1, 'x', std::string("Ruby"))));
|
||||
BOOST_TEST((erase(t1, end(t1)) == make_vector(1, 'x', 3.3, std::string("Ruby"))));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
typedef boost::mpl::begin<mpl_vec>::type mpl_vec_begin;
|
||||
typedef boost::mpl::advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
|
||||
typedef boost::mpl::next<mpl_vec_begin>::type n1;
|
||||
typedef boost::mpl::next<n1>::type n2;
|
||||
typedef boost::mpl::next<n2>::type n3;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<mpl_vec_at3, n3>::value));
|
||||
|
||||
|
||||
std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl;
|
||||
BOOST_TEST((erase(mpl_vec(), mpl_vec_at3())
|
||||
== make_vector(1, 2, 3, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/set/set.hpp>
|
||||
#include <boost/fusion/container/generation/make_set.hpp>
|
||||
#include <boost/fusion/container/map/map.hpp>
|
||||
#include <boost/fusion/container/generation/make_map.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/container/set/convert.hpp>
|
||||
#include <boost/fusion/container/map/convert.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/erase_key.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
template <typename Set>
|
||||
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_TEST((*find<int>(set) == 1));
|
||||
BOOST_TEST((*find<double>(set) == 1.5));
|
||||
BOOST_TEST((*find<std::string>(set) == "hello"));
|
||||
}
|
||||
|
||||
typedef boost::mpl::int_<1> _1;
|
||||
typedef boost::mpl::int_<2> _2;
|
||||
typedef boost::mpl::int_<3> _3;
|
||||
typedef boost::mpl::int_<4> _4;
|
||||
|
||||
template <typename Map>
|
||||
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_TEST(((*find<_1>(map)).second == 1));
|
||||
BOOST_TEST(((*find<_3>(map)).second == 1.5));
|
||||
BOOST_TEST(((*find<_4>(map)).second == std::string("hello")));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using boost::fusion::pair;
|
||||
using boost::fusion::make_pair;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
test_set(as_set(erase_key<char>(make_set(1, 'x', 1.5, std::string("hello")))));
|
||||
test_map(as_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello"))));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,109 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator int() const
|
||||
{
|
||||
return 12345;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Tree>
|
||||
void
|
||||
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;
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = fusion::find_if_s<is_same<_,short> >(tree);
|
||||
float_iter fi = fusion::find_if_s<is_same<_,float> >(tree);
|
||||
|
||||
// they behave like ordinary Fusion iterators ...
|
||||
BOOST_TEST((*si == short('d')));
|
||||
BOOST_TEST((*fi == float(1)));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector<int, char, int, double> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36);
|
||||
|
||||
std::cout << *find_if_s<is_same<_, char> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if_s<is_same<_, char> >(v) == 'x'));
|
||||
|
||||
std::cout << *find_if_s<is_same<_, int> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if_s<is_same<_, int> >(v) == 12345));
|
||||
|
||||
std::cout << *find_if_s<is_same<_, double> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if_s<is_same<_, double> >(v) == 3.36));
|
||||
}
|
||||
|
||||
{
|
||||
using boost::mpl::vector;
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector<int, char, X, double> mpl_vec;
|
||||
BOOST_TEST((*find_if_s<is_same<_, X> >(mpl_vec()) == 12345));
|
||||
}
|
||||
|
||||
{
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::less;
|
||||
using boost::mpl::int_;
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector_c<int, 1, 2, 3, 4> mpl_vec;
|
||||
BOOST_TEST((*find_if_s<less<_, int_<3> > >(mpl_vec()) == 1));
|
||||
}
|
||||
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman, 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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
|
||||
struct print
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T const& v) const
|
||||
{
|
||||
std::cout << "[ " << v << " ] ";
|
||||
}
|
||||
};
|
||||
|
||||
struct increment
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T& v) const
|
||||
{
|
||||
++v;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
{
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type v(1, 'x', 3.3, "Ruby");
|
||||
for_each_s(v, print());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type v(1, 'x', 3.3, "Ruby");
|
||||
for_each_s(v, increment());
|
||||
std::cout << v << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
|
||||
fusion::for_each_s(mpl_vec(), print());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
fusion::for_each_s(
|
||||
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,43 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/filter.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
typedef boost::fusion::vector<char,double,char> vector_type;
|
||||
vector_type t('a', 6.6, 'b');
|
||||
|
||||
{
|
||||
std::cout << filter<char>(t) << std::endl;
|
||||
BOOST_TEST((filter<char>(t)
|
||||
== make_vector('a', 'b')));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector<char,double,char> mpl_vec;
|
||||
BOOST_TEST((filter<char>(mpl_vec())
|
||||
== make_vector('\0', '\0')));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/filter_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<Y-object>";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
using boost::mpl::_;
|
||||
using boost::mpl::not_;
|
||||
using boost::is_class;
|
||||
using boost::is_same;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing filter_if
|
||||
|
||||
X x; Y y;
|
||||
typedef boost::fusion::vector<Y, char, long, X, bool, double> vector_type;
|
||||
vector_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << filter_if<not_<is_class<_> > >(t) << std::endl;
|
||||
BOOST_TEST((filter_if<not_<is_class<_> > >(t)
|
||||
== make_vector('@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << filter_if<is_class<_> >(t) << std::endl;
|
||||
BOOST_TEST((filter_if<is_class<_> >(t)
|
||||
== make_vector(y, x)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector<Y, char, long, X, bool> mpl_vec;
|
||||
BOOST_TEST((filter_if<not_<is_class<_> > >(mpl_vec())
|
||||
== make_vector(char(), long(), bool())));
|
||||
BOOST_TEST((filter_if<is_class<_> >(mpl_vec())
|
||||
== make_vector(y, x)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/set/set.hpp>
|
||||
#include <boost/fusion/container/map/map.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <string>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator int() const
|
||||
{
|
||||
return 12345;
|
||||
}
|
||||
};
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::identity;
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double> seq_type;
|
||||
seq_type seq(12345, 'x', 678910, 3.36);
|
||||
|
||||
std::cout << *boost::fusion::find<char>(seq) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
|
||||
|
||||
std::cout << *boost::fusion::find<int>(seq) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find<int>(seq) == 12345);
|
||||
|
||||
std::cout << *boost::fusion::find<double>(seq) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find<double>(seq) == 3.36);
|
||||
|
||||
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
|
||||
}
|
||||
|
||||
{
|
||||
typedef set<int, char, double> seq_type;
|
||||
seq_type seq(12345, 'x', 3.36);
|
||||
std::cout << *boost::fusion::find<char>(seq) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find<char>(seq) == 'x');
|
||||
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
|
||||
}
|
||||
|
||||
{
|
||||
typedef map<
|
||||
pair<int, char>
|
||||
, pair<double, std::string> >
|
||||
map_type;
|
||||
|
||||
map_type seq(
|
||||
make_pair<int>('X')
|
||||
, make_pair<double>("Men"));
|
||||
|
||||
std::cout << *boost::fusion::find<int>(seq) << std::endl;
|
||||
std::cout << *boost::fusion::find<double>(seq) << std::endl;
|
||||
BOOST_TEST((*boost::fusion::find<int>(seq)).second == 'X');
|
||||
BOOST_TEST((*boost::fusion::find<double>(seq)).second == "Men");
|
||||
BOOST_TEST(boost::fusion::find<bool>(seq) == boost::fusion::end(seq));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector<int, char, X, double> mpl_vec;
|
||||
BOOST_TEST((*boost::fusion::find<X>(mpl_vec()) == 12345));
|
||||
BOOST_TEST(boost::fusion::find<bool>(mpl_vec()) == boost::fusion::end(mpl_vec()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator int() const
|
||||
{
|
||||
return 12345;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector<int, char, int, double> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36);
|
||||
|
||||
std::cout << *find_if<is_same<_, char> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if<is_same<_, char> >(v) == 'x'));
|
||||
|
||||
std::cout << *find_if<is_same<_, int> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if<is_same<_, int> >(v) == 12345));
|
||||
|
||||
std::cout << *find_if<is_same<_, double> >(v) << std::endl;
|
||||
BOOST_TEST((*find_if<is_same<_, double> >(v) == 3.36));
|
||||
}
|
||||
|
||||
{
|
||||
using boost::mpl::vector;
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector<int, char, X, double> mpl_vec;
|
||||
BOOST_TEST((*find_if<is_same<_, X> >(mpl_vec()) == 12345));
|
||||
}
|
||||
|
||||
{
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::less;
|
||||
using boost::mpl::int_;
|
||||
using boost::is_same;
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef vector_c<int, 1, 2, 3, 4> mpl_vec;
|
||||
BOOST_TEST((*find_if<less<_, int_<3> > >(mpl_vec()) == 1));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,222 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/fold.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using boost::mpl::if_;
|
||||
using boost::mpl::int_;
|
||||
using boost::is_same;
|
||||
|
||||
struct add_ints_only
|
||||
{
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename T, typename State>
|
||||
struct result<add_ints_only(T,State)>
|
||||
{
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<State>::type>::type type;
|
||||
};
|
||||
|
||||
template <typename T, typename State>
|
||||
State const&
|
||||
operator()(T const& x, State const& state) const
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
int
|
||||
operator()(int x, int state) const
|
||||
{
|
||||
return x + state;
|
||||
}
|
||||
};
|
||||
|
||||
struct count_ints
|
||||
{
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template <typename T, typename CountT>
|
||||
struct result<count_ints(T,CountT)>
|
||||
{
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<T>::type>::type elem;
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_reference<CountT>::type>::type state;
|
||||
|
||||
typedef typename
|
||||
if_<
|
||||
is_same<elem, int>
|
||||
, typename boost::mpl::next<state>::type
|
||||
, state
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename T, typename CountT>
|
||||
typename result<count_ints(T, CountT)>::type
|
||||
operator()(T const&, CountT const&) const
|
||||
{
|
||||
typedef typename result<count_ints(T, CountT)>::type result;
|
||||
return result();
|
||||
}
|
||||
};
|
||||
|
||||
struct appender
|
||||
{
|
||||
typedef std::string result_type;
|
||||
|
||||
std::string operator()(char c, std::string const& str) const
|
||||
{
|
||||
return str + c;
|
||||
}
|
||||
};
|
||||
|
||||
struct lvalue_adder
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename T0, typename T1>
|
||||
struct result<lvalue_adder(T0&, T1)>
|
||||
{
|
||||
// Second argument still needs to support rvalues - see definition of fusion::fold
|
||||
typedef T0 type;
|
||||
};
|
||||
|
||||
template<typename T0, typename T1>
|
||||
T0 operator()(T0& lhs, T1 const& rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
int add(int lhs, int rhs)
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36);
|
||||
int result = fold(v, 0, add_ints_only());
|
||||
std::cout << result << std::endl;
|
||||
BOOST_TEST(result == 12345+678910);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int> vector_type;
|
||||
vector_type v(12345);
|
||||
|
||||
int n = fusion::fold(v, int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 1);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double, int> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36, 8756);
|
||||
|
||||
int n = fusion::fold(v, int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector<int, char, int, double, int> mpl_vec;
|
||||
int n = fusion::fold(mpl_vec(), int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(fusion::fold(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
|
||||
== "abcde");
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, int> vec(1,2);
|
||||
BOOST_TEST(fusion::fold(vec, 0, lvalue_adder()) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, int> vec(1,2);
|
||||
BOOST_TEST(fusion::fold(vec, 0, add) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36);
|
||||
int result = accumulate(v, 0, add_ints_only());
|
||||
std::cout << result << std::endl;
|
||||
BOOST_TEST(result == 12345+678910);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int> vector_type;
|
||||
vector_type v(12345);
|
||||
|
||||
int n = fusion::accumulate(v, int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 1);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double, int> vector_type;
|
||||
vector_type v(12345, 'x', 678910, 3.36, 8756);
|
||||
|
||||
int n = fusion::accumulate(v, int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector<int, char, int, double, int> mpl_vec;
|
||||
int n = fusion::accumulate(mpl_vec(), int_<0>(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(fusion::accumulate(fusion::make_vector('a','b','c','d','e'), std::string(""), appender())
|
||||
== "abcde");
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, int> vec(1,2);
|
||||
BOOST_TEST(fusion::accumulate(vec, 0, add) == 3);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
struct print
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T const& v) const
|
||||
{
|
||||
std::cout << "[ " << v << " ] ";
|
||||
}
|
||||
};
|
||||
|
||||
struct increment
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T& v) const
|
||||
{
|
||||
++v;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
{
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type v(1, 'x', 3.3, "Ruby");
|
||||
for_each(v, print());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type v(1, 'x', 3.3, "Ruby");
|
||||
for_each(v, increment());
|
||||
std::cout << v << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
|
||||
fusion::for_each(mpl_vec(), print());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/insert.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/advance.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::advance;
|
||||
using boost::mpl::int_;
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing insert
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
vector_iterator<vector_type, 2> pos(t1);
|
||||
|
||||
std::cout << insert(t1, pos, 123456) << std::endl;
|
||||
BOOST_TEST((insert(t1, pos, 123456)
|
||||
== make_vector(1, 'x', 123456, 3.3, s)));
|
||||
|
||||
std::cout << insert(t1, end(t1), 123456) << std::endl;
|
||||
BOOST_TEST((insert(t1, end(t1), 123456)
|
||||
== make_vector(1, 'x', 3.3, s, 123456)));
|
||||
|
||||
std::cout << insert(t1, begin(t1), "glad") << std::endl;
|
||||
BOOST_TEST((insert(t1, begin(t1), "glad")
|
||||
== make_vector(std::string("glad"), 1, 'x', 3.3, s)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
typedef mpl::begin<mpl_vec>::type mpl_vec_begin;
|
||||
typedef advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
|
||||
|
||||
std::cout << fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>()) << std::endl;
|
||||
BOOST_TEST((fusion::insert(mpl_vec(), mpl_vec_at3(), int_<66>())
|
||||
== make_vector(1, 2, 3, 66, 4, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/insert_range.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/advance.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::advance;
|
||||
using boost::mpl::int_;
|
||||
namespace fusion = boost::fusion;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing insert_range
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
vector_iterator<vector_type, 2> pos(t1);
|
||||
|
||||
typedef vector<int, char> vector_type2;
|
||||
vector_type2 t2(999, 'z');
|
||||
|
||||
std::cout << insert_range(t1, pos, t2) << std::endl;
|
||||
BOOST_TEST((insert_range(t1, pos, t2)
|
||||
== make_vector(1, 'x', 999, 'z', 3.3, s)));
|
||||
|
||||
std::cout << insert_range(t1, end(t1), t2) << std::endl;
|
||||
BOOST_TEST((insert_range(t1, end(t1), t2)
|
||||
== make_vector(1, 'x', 3.3, s, 999, 'z')));
|
||||
|
||||
std::cout << insert_range(t1, begin(t1), t2) << std::endl;
|
||||
BOOST_TEST((insert_range(t1, begin(t1), t2)
|
||||
== make_vector(999, 'z', 1, 'x', 3.3, s)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
typedef mpl::begin<mpl_vec>::type mpl_vec_begin;
|
||||
typedef advance<mpl_vec_begin, int_<3> >::type mpl_vec_at3;
|
||||
typedef vector_c<int, -1, -2> mpl_vec2;
|
||||
|
||||
std::cout << fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2()) << std::endl;
|
||||
BOOST_TEST((fusion::insert_range(mpl_vec(), mpl_vec_at3(), mpl_vec2())
|
||||
== make_vector(1, 2, 3, -1, -2, 4, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/algorithm/transformation/join.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/mpl/vector/vector10_c.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
BOOST_TEST(join(make_vector(1,2), make_vector('a','b')) == make_vector(1,2,'a','b'));
|
||||
}
|
||||
{
|
||||
typedef boost::mpl::vector2_c<int,1,2> vec1;
|
||||
typedef boost::mpl::vector2_c<int,3,4> vec2;
|
||||
BOOST_TEST(join(vec1(), vec2()) == make_vector(1,2,3,4));
|
||||
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/algorithm/query/none.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct search_for
|
||||
{
|
||||
explicit search_for(int search)
|
||||
: search(search)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
bool operator()(T const& v) const
|
||||
{
|
||||
return v == search;
|
||||
}
|
||||
|
||||
int search;
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 > 4)));
|
||||
BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 < 0)));
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
|
||||
BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 == 1)));
|
||||
BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
|
||||
// We cannot use lambda here as mpl vec iterators return
|
||||
// rvalues, and lambda needs lvalues.
|
||||
BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4)));
|
||||
BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/pop_back.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing pop_back
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << pop_back(t1) << std::endl;
|
||||
BOOST_TEST((pop_back(t1) == make_vector(1, 'x', 3.3)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
std::cout << boost::fusion::pop_back(mpl_vec()) << std::endl;
|
||||
BOOST_TEST((boost::fusion::pop_back(mpl_vec()) == make_vector(1, 2, 3, 4)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/pop_front.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing pop_front
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << pop_front(t1) << std::endl;
|
||||
BOOST_TEST((pop_front(t1) == make_vector('x', 3.3, s)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
std::cout << boost::fusion::pop_front(mpl_vec()) << std::endl;
|
||||
BOOST_TEST((boost::fusion::pop_front(mpl_vec()) == make_vector(2, 3, 4, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <string>
|
||||
|
||||
struct plus_one
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T& v) const
|
||||
{
|
||||
v += 1;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing push_back
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, 123456) << std::endl;
|
||||
BOOST_TEST((push_back(t1, 123456)
|
||||
== make_vector(1, 'x', 3.3, s, 123456)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, "funny") << std::endl;
|
||||
BOOST_TEST((push_back(t1, "funny")
|
||||
== make_vector(1, 'x', 3.3, s, std::string("funny"))));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, t1) << std::endl;
|
||||
BOOST_TEST((push_back(t1, t1)
|
||||
== make_vector(1, 'x', 3.3, s, t1)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
std::cout << boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>()) << std::endl;
|
||||
BOOST_TEST((boost::fusion::push_back(mpl_vec(), boost::mpl::int_<6>())
|
||||
== make_vector(1, 2, 3, 4, 5, 6)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/algorithm/transformation/push_front.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing push_front
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << push_front(t1, 123456) << std::endl;
|
||||
BOOST_TEST((push_front(t1, 123456)
|
||||
== make_vector(123456, 1, 'x', 3.3, s)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_front(t1, "lively") << std::endl;
|
||||
BOOST_TEST((push_front(t1, "lively")
|
||||
== make_vector(std::string("lively"), 1, 'x', 3.3, s)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
|
||||
std::cout << boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>()) << std::endl;
|
||||
BOOST_TEST((boost::fusion::push_front(mpl_vec(), boost::mpl::int_<1>())
|
||||
== make_vector(1, 2, 3, 4, 5, 6)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/remove.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<Y-object>";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::identity;
|
||||
using boost::mpl::vector;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing remove
|
||||
|
||||
X x; Y y;
|
||||
typedef fusion::vector<Y, char, long, X, bool, double> vector_type;
|
||||
vector_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << fusion::remove<X>(t) << std::endl;
|
||||
BOOST_TEST((fusion::remove<X>(t)
|
||||
== make_vector(y, '@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << fusion::remove<Y>(t) << std::endl;
|
||||
BOOST_TEST((fusion::remove<Y>(t)
|
||||
== make_vector('@', 987654, x, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << fusion::remove<long>(t) << std::endl;
|
||||
BOOST_TEST((fusion::remove<long>(t)
|
||||
== make_vector(y, '@', x, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool> mpl_vec;
|
||||
BOOST_TEST((fusion::remove<X>(mpl_vec())
|
||||
== vector<Y, char, long, bool>()));
|
||||
BOOST_TEST((fusion::remove<Y>(mpl_vec())
|
||||
== vector<char, long, X, bool>()));
|
||||
BOOST_TEST((fusion::remove<long>(mpl_vec())
|
||||
== vector<Y, char, X, bool>()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/remove_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<Y-object>";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector;
|
||||
using boost::mpl::_;
|
||||
using boost::mpl::not_;
|
||||
using boost::is_class;
|
||||
using boost::is_same;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing remove_if
|
||||
|
||||
X x; Y y;
|
||||
typedef fusion::vector<Y, char, long, X, bool, double> vector_type;
|
||||
vector_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << remove_if<not_<is_class<_> > >(t) << std::endl;
|
||||
BOOST_TEST((remove_if<not_<is_class<_> > >(t)
|
||||
== make_vector(y, x)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << remove_if<is_class<_> >(t) << std::endl;
|
||||
BOOST_TEST((remove_if<is_class<_> >(t)
|
||||
== make_vector('@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool> mpl_vec;
|
||||
BOOST_TEST((remove_if<not_<is_class<_> > >(mpl_vec())
|
||||
== vector<Y, X>()));
|
||||
BOOST_TEST((remove_if<is_class<_> >(mpl_vec())
|
||||
== vector<char, long, bool>()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.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/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/replace.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing replace
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, long, char const*> vector_type;
|
||||
vector_type t1(1, 'x', 3, s);
|
||||
|
||||
{
|
||||
std::cout << replace(t1, 'x', 'y') << std::endl;
|
||||
BOOST_TEST((replace(t1, 'x', 'y')
|
||||
== make_vector(1, 'y', 3, s)));
|
||||
}
|
||||
|
||||
{
|
||||
char const* s2 = "funny";
|
||||
std::cout << replace(t1, s, s2) << std::endl;
|
||||
BOOST_TEST((replace(t1, s, s2)
|
||||
== make_vector(1, 'x', 3, s2)));
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.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/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/replace_if.hpp>
|
||||
#include <string>
|
||||
|
||||
struct gt3
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(T x) const
|
||||
{
|
||||
return x > 3;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing replace
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, short, double, long, char const*, float> vector_type;
|
||||
vector_type t1(1, 2, 3.3, 4, s, 5.5);
|
||||
|
||||
{
|
||||
std::cout << replace_if(t1, gt3(), -456) << std::endl;
|
||||
BOOST_TEST((replace_if(t1, gt3(), -456)
|
||||
== make_vector(1, 2, -456, -456, s, -456)));
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/reverse.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing the reverse_view
|
||||
|
||||
{
|
||||
typedef boost::mpl::range_c<int, 5, 9> mpl_list1;
|
||||
mpl_list1 sequence;
|
||||
|
||||
std::cout << reverse(sequence) << std::endl;
|
||||
BOOST_TEST((reverse(sequence) == make_vector(8, 7, 6, 5)));
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "Hi Kim";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type t(123, 'x', 3.36, s);
|
||||
|
||||
std::cout << reverse(t) << std::endl;
|
||||
BOOST_TEST((reverse(t) == make_vector(s, 3.36, 'x', 123)));
|
||||
std::cout << reverse(reverse(t)) << std::endl;
|
||||
BOOST_TEST((reverse(reverse(t)) == t));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
@ -1,157 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/transform.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
|
||||
struct square
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename T>
|
||||
struct result<square(T)>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int operator()(T x) const
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
};
|
||||
|
||||
struct add
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template <typename A, typename B>
|
||||
struct result<add(A, B)>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename A, typename B>
|
||||
int operator()(A a, B b) const
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
};
|
||||
|
||||
struct unary_lvalue_transform
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename T>
|
||||
struct result<unary_lvalue_transform(T&)>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
T* operator()(T& t) const
|
||||
{
|
||||
return &t;
|
||||
}
|
||||
};
|
||||
|
||||
int twice(int v)
|
||||
{
|
||||
return v*2;
|
||||
}
|
||||
|
||||
struct binary_lvalue_transform
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename T0, typename T1>
|
||||
struct result<binary_lvalue_transform(T0&,T1&)>
|
||||
{
|
||||
typedef T0* type;
|
||||
};
|
||||
|
||||
template<typename T0, typename T1>
|
||||
T0* operator()(T0& t0, T1&) const
|
||||
{
|
||||
return &t0;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::range_c;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing the transform
|
||||
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, int, int> tup1(1, 2, 3);
|
||||
BOOST_TEST(transform(tup1, twice) == make_vector(2,4,6));
|
||||
}
|
||||
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/algorithm/transformation/zip.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
BOOST_TEST(zip(make_vector(1,2), make_vector('a','b')) == make_vector(make_vector(1,'a'), make_vector(2,'b')));
|
||||
BOOST_TEST(
|
||||
zip(
|
||||
make_vector(1,2),
|
||||
make_vector('a','b'),
|
||||
make_vector(-1,-2))
|
||||
== make_vector(
|
||||
make_vector(1,'a',-1),
|
||||
make_vector(2,'b',-2))); // Zip more than 2 sequences
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/algorithm/transformation/zip.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
const vector2<int,int> shorter(1,2);
|
||||
const vector3<char,char,char> longer('a', 'b', 'c');
|
||||
const vector2<vector2<int,char>, vector2<int,char> > result(vector2<int,char>(1,'a'), vector2<int,char>(2,'b'));
|
||||
BOOST_TEST(zip(shorter, longer) == result);
|
||||
}
|
||||
{
|
||||
const vector3<int,int,int> longer(1,2,3);
|
||||
const vector2<char,char> shorter('a', 'b');
|
||||
const vector2<vector2<int,char>, vector2<int,char> > result(vector2<int,char>(1,'a'), vector2<int,char>(2,'b'));
|
||||
BOOST_TEST(zip(longer, shorter) == result);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 Joel de Guzman
|
||||
Copyright (c) 2007 Dan Marsden
|
||||
|
||||
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.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/zip.hpp>
|
||||
#include <boost/fusion/support/unused.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
vector<int, int> iv(1,2);
|
||||
vector<char, char> cv('a', 'b');
|
||||
BOOST_TEST(at_c<0>(at_c<0>(zip(iv, unused, cv))) == 1);
|
||||
BOOST_TEST(at_c<2>(at_c<0>(zip(iv, unused, cv))) == 'a');
|
||||
|
||||
BOOST_TEST(at_c<0>(at_c<1>(zip(iv, unused, cv))) == 2);
|
||||
BOOST_TEST(at_c<2>(at_c<1>(zip(iv, unused, cv))) == 'b');
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,97 +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/fused.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
|
||||
typedef fusion::fused< test_func<> > ff;
|
||||
ff fused_func;
|
||||
|
||||
typedef fusion::fused< test_func<noncopyable> & > ffr;
|
||||
ffr fused_func_ref(f);
|
||||
|
||||
typedef fusion::fused< test_func<> const > ffc;
|
||||
ffc fused_func_c;
|
||||
|
||||
typedef fusion::fused< test_func<> > const ffc2;
|
||||
ffc2 fused_func_c2;
|
||||
|
||||
typedef fusion::fused< test_func<noncopyable> const & > ffcr;
|
||||
ffcr fused_func_c_ref(f);
|
||||
|
||||
typedef fusion::vector<int,char> vec;
|
||||
vec lv_vec(1,'\004');
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<boost::result_of<ff(vec)>::type, int>));
|
||||
BOOST_TEST(fused_func(lv_vec) == 1);
|
||||
BOOST_MPL_ASSERT((boost::is_same<boost::result_of<ffr(vec)>::type, int>));
|
||||
BOOST_TEST(fused_func_c(lv_vec) == 0);
|
||||
BOOST_MPL_ASSERT((boost::is_same<boost::result_of<ffc(vec)>::type, int>));
|
||||
BOOST_TEST(fused_func_c2(lv_vec) == 0);
|
||||
BOOST_TEST(fused_func_ref(lv_vec) == 1);
|
||||
BOOST_MPL_ASSERT((boost::is_same<boost::result_of<ffcr(vec)>::type, int>));
|
||||
BOOST_TEST(fused_func_c_ref(lv_vec) == 0);
|
||||
|
||||
BOOST_TEST(fused_func(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fused_func_c(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fused_func_c2(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fused_func_ref(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fused_func_c_ref(fusion::make_vector(2,'\003')) == 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,83 +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/fused_function_object.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
struct result;
|
||||
|
||||
template<class Self, typename T0, typename T1>
|
||||
struct result< Self(T0, T1) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
fusion::fused_function_object< test_func<> > fused_func;
|
||||
fusion::fused_function_object< test_func<noncopyable> & > fused_func_ref(f);
|
||||
fusion::fused_function_object< test_func<> const > fused_func_c;
|
||||
fusion::fused_function_object< test_func<> > const fused_func_c2;
|
||||
fusion::fused_function_object< test_func<noncopyable> const & > fused_func_c_ref(f);
|
||||
|
||||
fusion::vector<int,char> lv_vec(1,'\004');
|
||||
BOOST_TEST(fused_func(lv_vec) == 1);
|
||||
BOOST_TEST(fused_func_c(lv_vec) == 0);
|
||||
BOOST_TEST(fused_func_c2(lv_vec) == 0);
|
||||
BOOST_TEST(fused_func_ref(lv_vec) == 1);
|
||||
BOOST_TEST(fused_func_c_ref(lv_vec) == 0);
|
||||
|
||||
BOOST_TEST(fused_func(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fused_func_c(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fused_func_c2(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fused_func_ref(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fused_func_c_ref(fusion::make_vector(2,'\003')) == 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,82 +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/fused_procedure.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
|
||||
int effect;
|
||||
|
||||
#define CHECK_EFFECT(t,e) \
|
||||
{ \
|
||||
effect = 1234567; t; \
|
||||
BOOST_TEST(effect == e); \
|
||||
}
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return effect = 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return effect = 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return effect = 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return effect = 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
fusion::fused_procedure< test_func<> > fused_proc;
|
||||
fusion::fused_procedure< test_func<noncopyable> & > fused_proc_ref(f);
|
||||
fusion::fused_procedure< test_func<> const > fused_proc_c;
|
||||
fusion::fused_procedure< test_func<> > const fused_proc_c2;
|
||||
fusion::fused_procedure< test_func<noncopyable> const & > fused_proc_c_ref(f);
|
||||
|
||||
fusion::vector<int,char> lv_vec(1,'\004');
|
||||
CHECK_EFFECT(fused_proc(lv_vec), 1);
|
||||
CHECK_EFFECT(fused_proc_c(lv_vec), 0);
|
||||
CHECK_EFFECT(fused_proc_c2(lv_vec), 0);
|
||||
CHECK_EFFECT(fused_proc_ref(lv_vec), 1);
|
||||
CHECK_EFFECT(fused_proc_c_ref(lv_vec), 0);
|
||||
|
||||
CHECK_EFFECT(fused_proc(fusion::make_vector(2,'\003')), 1);
|
||||
CHECK_EFFECT(fused_proc_c(fusion::make_vector(2,'\003')), 0);
|
||||
CHECK_EFFECT(fused_proc_c2(fusion::make_vector(2,'\003')), 0);
|
||||
CHECK_EFFECT(fused_proc_ref(fusion::make_vector(2,'\003')), 1);
|
||||
CHECK_EFFECT(fused_proc_c_ref(fusion::make_vector(2,'\003')), 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,394 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2006 João Abecasis
|
||||
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/invocation/invoke.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/view/single_view.hpp>
|
||||
#include <boost/fusion/view/iterator_range.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
struct object {};
|
||||
struct object_nc : boost::noncopyable {};
|
||||
|
||||
struct fobj
|
||||
{
|
||||
// Handle nullary separately to exercise result_of support
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, typename T0>
|
||||
struct result< Self(T0) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <class Self, typename T0, typename T1>
|
||||
struct result< Self(T0, T1) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <class Self, typename T0, typename T1, typename T2>
|
||||
struct result< Self(T0, T1, T2) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
int operator()(int i) { return 2 + i; }
|
||||
int operator()(int i) const { return 3 + i; }
|
||||
|
||||
int operator()(int i, object &) { return 4 + i; }
|
||||
int operator()(int i, object &) const { return 5 + i; }
|
||||
int operator()(int i, object const &) { return 6 + i; }
|
||||
int operator()(int i, object const &) const { return 7 + i; }
|
||||
|
||||
int operator()(int i, object &, object_nc &) { return 10 + i; }
|
||||
int operator()(int i, object &, object_nc &) const { return 11 + i; }
|
||||
};
|
||||
|
||||
struct nullary_fobj
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
int operator()() { return 0; }
|
||||
int operator()() const { return 1; }
|
||||
};
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
{
|
||||
// Handle nullary separately to exercise result_of support
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, typename T0>
|
||||
struct result< Self(T0)>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
int operator()(int i) { return 14 + i; }
|
||||
int operator()(int i) const { return 15 + i; }
|
||||
};
|
||||
|
||||
struct nullary_fobj_nc
|
||||
: boost::noncopyable
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
int operator()() { return 12; }
|
||||
int operator()() const { return 13; }
|
||||
};
|
||||
|
||||
int nullary() { return 16; }
|
||||
int unary(int i) { return 17 + i; }
|
||||
int binary1(int i, object &) { return 18 + i; }
|
||||
int binary2(int i, object const &) { return 19 + i; }
|
||||
|
||||
typedef int (* func_ptr)(int);
|
||||
typedef int (* const c_func_ptr)(int);
|
||||
typedef int (* volatile v_func_ptr)(int);
|
||||
typedef int (* const volatile cv_func_ptr)(int);
|
||||
|
||||
func_ptr func_ptr1 = &unary;
|
||||
c_func_ptr func_ptr2 = &unary;
|
||||
v_func_ptr func_ptr3 = &unary;
|
||||
cv_func_ptr func_ptr4 = &unary;
|
||||
|
||||
class members
|
||||
{
|
||||
public:
|
||||
int data;
|
||||
|
||||
members()
|
||||
: data(20)
|
||||
{ }
|
||||
|
||||
int nullary() { return data + 1; }
|
||||
int nullary_c() const { return data + 2; }
|
||||
int unary(int i) { return data + 3 + i; }
|
||||
int unary_c(int i) const { return data + 4 + i; }
|
||||
int binary(int i, object) { return data + 5 + i; }
|
||||
int binary_c(int i, object) const { return data + 6 + i; }
|
||||
};
|
||||
|
||||
struct derived
|
||||
: members
|
||||
{
|
||||
};
|
||||
|
||||
typedef int element1_type;
|
||||
typedef object element2_type;
|
||||
typedef object_nc & element3_type;
|
||||
|
||||
int element1 = 100;
|
||||
object element2 = object();
|
||||
object_nc element3;
|
||||
|
||||
members that;
|
||||
|
||||
std::auto_ptr<members> spt_that(new members);
|
||||
std::auto_ptr<members const> spt_that_c(new members);
|
||||
|
||||
fusion::single_view<members > sv_obj_ctx( that);
|
||||
fusion::single_view<members &> sv_ref_ctx( that);
|
||||
fusion::single_view<members *> sv_ptr_ctx(& that);
|
||||
fusion::single_view<members const > sv_obj_c_ctx( that);
|
||||
fusion::single_view<members const &> sv_ref_c_ctx( that);
|
||||
fusion::single_view<members const *> sv_ptr_c_ctx(& that);
|
||||
fusion::single_view<std::auto_ptr<members> const &> sv_spt_ctx(spt_that);
|
||||
fusion::single_view< std::auto_ptr<members const> const &> sv_spt_c_ctx(spt_that_c);
|
||||
|
||||
derived derived_that;
|
||||
|
||||
std::auto_ptr<derived> spt_derived_that(new derived);
|
||||
std::auto_ptr<derived const> spt_derived_that_c(new derived);
|
||||
|
||||
fusion::single_view<derived > sv_obj_d_ctx( derived_that);
|
||||
fusion::single_view<derived &> sv_ref_d_ctx( derived_that);
|
||||
fusion::single_view<derived *> sv_ptr_d_ctx(& derived_that);
|
||||
fusion::single_view<derived const > sv_obj_c_d_ctx( derived_that);
|
||||
fusion::single_view<derived const &> sv_ref_c_d_ctx( derived_that);
|
||||
fusion::single_view<derived const *> sv_ptr_c_d_ctx(& derived_that);
|
||||
fusion::single_view<std::auto_ptr<derived> const &> sv_spt_d_ctx(spt_derived_that);
|
||||
fusion::single_view< std::auto_ptr<derived const> const &> sv_spt_c_d_ctx(spt_derived_that_c);
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<0>)
|
||||
{
|
||||
// Function Objects
|
||||
|
||||
nullary_fobj f;
|
||||
|
||||
BOOST_TEST(f () == fusion::invoke(f , seq ));
|
||||
BOOST_TEST(f () == fusion::invoke(f , const_(seq)));
|
||||
|
||||
// Note: The function object is taken by value, so we request the copy
|
||||
// to be const with an explicit template argument. We can also request
|
||||
// the function object to be pased by reference...
|
||||
BOOST_TEST(const_(f)() == fusion::invoke<nullary_fobj const >(const_(f), seq ));
|
||||
BOOST_TEST(const_(f)() == fusion::invoke<nullary_fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
nullary_fobj_nc nc_f;
|
||||
// ...and we further ensure there is no copying in this case, using a
|
||||
// noncopyable function object.
|
||||
BOOST_TEST(nc_f () == fusion::invoke<nullary_fobj_nc &>(nc_f , seq ));
|
||||
BOOST_TEST(nc_f () == fusion::invoke<nullary_fobj_nc &>(nc_f , const_(seq)));
|
||||
BOOST_TEST(const_(nc_f)() == fusion::invoke<nullary_fobj_nc const &>(const_(nc_f), seq ));
|
||||
BOOST_TEST(const_(nc_f)() == fusion::invoke<nullary_fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
|
||||
// Builtin Functions
|
||||
|
||||
// Call through ref/ptr to function
|
||||
BOOST_TEST(nullary() == fusion::invoke<int (&)()>(nullary, seq));
|
||||
BOOST_TEST(nullary() == fusion::invoke(& nullary, seq));
|
||||
|
||||
// Call through ptr to member function
|
||||
// Note: The non-const function members::nullary can't be invoked with
|
||||
// fusion::join(sv_obj_ctx,seq)), which is const and so is its first element
|
||||
BOOST_TEST(that.nullary() == fusion::invoke(& members::nullary, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.nullary() == fusion::invoke(& members::nullary, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.nullary() == fusion::invoke(& members::nullary, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
BOOST_TEST(that.nullary_c() == fusion::invoke(& members::nullary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
|
||||
// Pointer to data member
|
||||
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_obj_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_ref_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_ptr_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_spt_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_obj_c_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_ref_c_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_spt_c_ctx,seq)));
|
||||
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_obj_d_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_ref_d_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_ptr_d_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == (fusion::invoke(& members::data, fusion::join(sv_spt_d_ctx,seq)) = that.data));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_obj_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_ref_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_ptr_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.data == fusion::invoke(& members::data, fusion::join(sv_spt_c_d_ctx,seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<1>)
|
||||
{
|
||||
fobj f;
|
||||
BOOST_TEST(f(element1) == fusion::invoke(f , seq ));
|
||||
BOOST_TEST(f(element1) == fusion::invoke(f , const_(seq)));
|
||||
BOOST_TEST(const_(f)(element1) == fusion::invoke<fobj const >(const_(f), seq ));
|
||||
BOOST_TEST(const_(f)(element1) == fusion::invoke<fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
fobj_nc nc_f;
|
||||
BOOST_TEST(nc_f(element1) == fusion::invoke<fobj_nc &>(nc_f, seq ));
|
||||
BOOST_TEST(nc_f(element1) == fusion::invoke<fobj_nc &>(nc_f, const_(seq)));
|
||||
BOOST_TEST(const_(nc_f)(element1) == fusion::invoke<fobj_nc const &>(const_(nc_f), seq ));
|
||||
BOOST_TEST(const_(nc_f)(element1) == fusion::invoke<fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
|
||||
BOOST_TEST(unary(element1) == fusion::invoke<int (&)(int)>(unary, seq));
|
||||
BOOST_TEST(func_ptr1(element1) == fusion::invoke(func_ptr1, seq));
|
||||
BOOST_TEST(func_ptr2(element1) == fusion::invoke(func_ptr2, seq));
|
||||
BOOST_TEST(func_ptr3(element1) == fusion::invoke(func_ptr3, seq));
|
||||
BOOST_TEST(func_ptr4(element1) == fusion::invoke(func_ptr4, seq));
|
||||
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_ref_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_ptr_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary(element1) == fusion::invoke(& members::unary, fusion::join(sv_spt_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_obj_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ref_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ptr_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_spt_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_obj_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ref_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ptr_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_spt_c_d_ctx,seq)));
|
||||
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<2>)
|
||||
{
|
||||
fobj f;
|
||||
BOOST_TEST(f (element1, element2) == fusion::invoke(f , seq));
|
||||
BOOST_TEST(f (element1, const_(element2)) == fusion::invoke(f , const_(seq)));
|
||||
BOOST_TEST(const_(f)(element1, element2) == fusion::invoke<fobj const>(const_(f), seq));
|
||||
BOOST_TEST(const_(f)(element1, const_(element2)) == fusion::invoke<fobj const>(const_(f), const_(seq)));
|
||||
|
||||
BOOST_TEST(binary1(element1, element2) == fusion::invoke(binary1, seq));
|
||||
BOOST_TEST(binary2(element1, element2) == fusion::invoke(binary2, seq));
|
||||
|
||||
BOOST_TEST(that.binary(element1,element2) == fusion::invoke(& members::binary, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.binary(element1,element2) == fusion::invoke(& members::binary, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.binary(element1,element2) == fusion::invoke(& members::binary, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
BOOST_TEST(that.binary_c(element1,element2) == fusion::invoke(& members::binary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<3>)
|
||||
{
|
||||
fobj f;
|
||||
|
||||
BOOST_TEST(f(element1, element2, element3) == fusion::invoke(f, seq));
|
||||
BOOST_TEST(const_(f)(element1, element2, element3) == fusion::invoke<fobj const>(const_(f), seq));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence(Sequence & seq)
|
||||
{
|
||||
test_sequence_n(seq, mpl::int_<fusion::result_of::size<Sequence>::value>());
|
||||
}
|
||||
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
BOOST_TEST(( is_same<
|
||||
fusion::result_of::invoke<int (*)(), fusion::vector0 >::type, int
|
||||
>::value ));
|
||||
// disabled until boost::result_of supports it
|
||||
// BOOST_TEST(( is_same<
|
||||
// fusion::result_of::invoke<int (*)(...), fusion::vector1<int> >::type, int
|
||||
// >::value ));
|
||||
BOOST_TEST(( is_same<
|
||||
fusion::result_of::invoke<int (members::*)(), fusion::vector1<members*> >::type, int
|
||||
>::value ));
|
||||
// disabled until boost::result_of supports it
|
||||
// BOOST_TEST(( is_same<
|
||||
// fusion::result_of::invoke<int (members::*)(...), fusion::vector2<members*,int> >::type, int
|
||||
// >::value ));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
|
||||
typedef fusion::vector<> vector0;
|
||||
typedef fusion::vector<element1_type> vector1;
|
||||
typedef fusion::vector<element1_type, element2_type> vector2;
|
||||
typedef fusion::vector<element1_type, element2_type, element3_type> vector3;
|
||||
|
||||
vector0 v0;
|
||||
vector1 v1(element1);
|
||||
vector2 v2(element1, element2);
|
||||
vector3 v3(element1, element2, element3);
|
||||
|
||||
test_sequence(v0);
|
||||
test_sequence(v1);
|
||||
test_sequence(v2);
|
||||
test_sequence(v3);
|
||||
|
||||
typedef fusion::list<> list0;
|
||||
typedef fusion::list<element1_type> list1;
|
||||
typedef fusion::list<element1_type, element2_type> list2;
|
||||
typedef fusion::list<element1_type, element2_type, element3_type> list3;
|
||||
|
||||
list0 l0;
|
||||
list1 l1(element1);
|
||||
list2 l2(element1, element2);
|
||||
list3 l3(element1, element2, element3);
|
||||
|
||||
test_sequence(l0);
|
||||
test_sequence(l1);
|
||||
test_sequence(l2);
|
||||
test_sequence(l3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,234 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2006 João Abecasis
|
||||
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/invocation/invoke_function_object.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/view/single_view.hpp>
|
||||
#include <boost/fusion/view/iterator_range.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
struct object {};
|
||||
struct object_nc : boost::noncopyable {};
|
||||
|
||||
struct fobj
|
||||
{
|
||||
// Handle nullary separately to exercise result_of support
|
||||
template <typename Sig>
|
||||
struct result;
|
||||
|
||||
template <class Self, typename T0>
|
||||
struct result< Self(T0) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <class Self, typename T0, typename T1>
|
||||
struct result< Self(T0, T1) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <class Self, typename T0, typename T1, typename T2>
|
||||
struct result< Self(T0, T1, T2) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
int operator()() { return 0; }
|
||||
int operator()() const { return 1; }
|
||||
|
||||
int operator()(int i) { return 2 + i; }
|
||||
int operator()(int i) const { return 3 + i; }
|
||||
|
||||
int operator()(int i, object &) { return 4 + i; }
|
||||
int operator()(int i, object &) const { return 5 + i; }
|
||||
int operator()(int i, object const &) { return 6 + i; }
|
||||
int operator()(int i, object const &) const { return 7 + i; }
|
||||
|
||||
int operator()(int i, object &, object_nc &) { return 10 + i; }
|
||||
int operator()(int i, object &, object_nc &) const { return 11 + i; }
|
||||
};
|
||||
|
||||
struct nullary_fobj
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
int operator()() { return 0; }
|
||||
int operator()() const { return 1; }
|
||||
};
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
{
|
||||
// Handle nullary separately to exercise result_of support
|
||||
template <typename T>
|
||||
struct result;
|
||||
|
||||
template <class Self, typename T0>
|
||||
struct result< Self(T0) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
int operator()(int i) { return 14 + i; }
|
||||
int operator()(int i) const { return 15 + i; }
|
||||
};
|
||||
|
||||
struct nullary_fobj_nc
|
||||
: boost::noncopyable
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
int operator()() { return 12; }
|
||||
int operator()() const { return 13; }
|
||||
};
|
||||
|
||||
|
||||
typedef int element1_type;
|
||||
typedef object element2_type;
|
||||
typedef object_nc & element3_type;
|
||||
|
||||
int element1 = 100;
|
||||
object element2 = object();
|
||||
object_nc element3;
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<0>)
|
||||
{
|
||||
// Function Objects
|
||||
|
||||
nullary_fobj f;
|
||||
BOOST_TEST(f () == fusion::invoke_function_object(f , seq ));
|
||||
BOOST_TEST(f () == fusion::invoke_function_object(f , const_(seq)));
|
||||
|
||||
// Note: The function object is taken by value, so we request the copy
|
||||
// to be const with an explicit template argument. We can also request
|
||||
// the function object to be pased by reference...
|
||||
BOOST_TEST(const_(f)() == fusion::invoke_function_object<nullary_fobj const >(const_(f), seq ));
|
||||
BOOST_TEST(const_(f)() == fusion::invoke_function_object<nullary_fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
nullary_fobj_nc nc_f;
|
||||
// ...and we further ensure there is no copying in this case, using a
|
||||
// noncopyable function object.
|
||||
BOOST_TEST(nc_f () == fusion::invoke_function_object<nullary_fobj_nc &>(nc_f , seq ));
|
||||
BOOST_TEST(nc_f () == fusion::invoke_function_object<nullary_fobj_nc &>(nc_f , const_(seq)));
|
||||
BOOST_TEST(const_(nc_f)() == fusion::invoke_function_object<nullary_fobj_nc const &>(const_(nc_f), seq ));
|
||||
BOOST_TEST(const_(nc_f)() == fusion::invoke_function_object<nullary_fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<1>)
|
||||
{
|
||||
fobj f;
|
||||
BOOST_TEST(f(element1) == fusion::invoke_function_object(f , seq ));
|
||||
BOOST_TEST(f(element1) == fusion::invoke_function_object(f , const_(seq)));
|
||||
BOOST_TEST(const_(f)(element1) == fusion::invoke_function_object<fobj const >(const_(f), seq ));
|
||||
BOOST_TEST(const_(f)(element1) == fusion::invoke_function_object<fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
fobj_nc nc_f;
|
||||
BOOST_TEST(nc_f(element1) == fusion::invoke_function_object<fobj_nc &>(nc_f, seq ));
|
||||
BOOST_TEST(nc_f(element1) == fusion::invoke_function_object<fobj_nc &>(nc_f, const_(seq)));
|
||||
BOOST_TEST(const_(nc_f)(element1) == fusion::invoke_function_object<fobj_nc const &>(const_(nc_f), seq ));
|
||||
BOOST_TEST(const_(nc_f)(element1) == fusion::invoke_function_object<fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<2>)
|
||||
{
|
||||
fobj f;
|
||||
BOOST_TEST(f (element1, element2) == fusion::invoke_function_object(f , seq));
|
||||
BOOST_TEST(f (element1, const_(element2)) == fusion::invoke_function_object(f , const_(seq)));
|
||||
BOOST_TEST(const_(f)(element1, element2) == fusion::invoke_function_object<fobj const>(const_(f), seq));
|
||||
BOOST_TEST(const_(f)(element1, const_(element2)) == fusion::invoke_function_object<fobj const>(const_(f), const_(seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<3>)
|
||||
{
|
||||
fobj f;
|
||||
|
||||
BOOST_TEST(f(element1, element2, element3) == fusion::invoke_function_object(f, seq));
|
||||
BOOST_TEST(const_(f)(element1, element2, element3) == fusion::invoke_function_object<fobj const>(const_(f), seq));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence(Sequence & seq)
|
||||
{
|
||||
test_sequence_n(seq, mpl::int_<fusion::result_of::size<Sequence>::value>());
|
||||
}
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
BOOST_TEST(( is_same< fusion::result_of::invoke_function_object< nullary_fobj, fusion::vector<> >::type, int >::value ));
|
||||
BOOST_TEST(( is_same< fusion::result_of::invoke_function_object< fobj, fusion::vector<element1_type> >::type, int >::value ));
|
||||
BOOST_TEST(( is_same< fusion::result_of::invoke_function_object< fobj, fusion::vector<element1_type,element2_type> >::type, int >::value ));
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
|
||||
typedef fusion::vector<> vector0;
|
||||
typedef fusion::vector<element1_type> vector1;
|
||||
typedef fusion::vector<element1_type, element2_type> vector2;
|
||||
typedef fusion::vector<element1_type, element2_type, element3_type> vector3;
|
||||
|
||||
vector0 v0;
|
||||
vector1 v1(element1);
|
||||
vector2 v2(element1, element2);
|
||||
vector3 v3(element1, element2, element3);
|
||||
|
||||
test_sequence(v0);
|
||||
test_sequence(v1);
|
||||
test_sequence(v2);
|
||||
test_sequence(v3);
|
||||
|
||||
typedef fusion::list<> list0;
|
||||
typedef fusion::list<element1_type> list1;
|
||||
typedef fusion::list<element1_type, element2_type> list2;
|
||||
typedef fusion::list<element1_type, element2_type, element3_type> list3;
|
||||
|
||||
list0 l0;
|
||||
list1 l1(element1);
|
||||
list2 l2(element1, element2);
|
||||
list3 l3(element1, element2, element3);
|
||||
|
||||
test_sequence(l0);
|
||||
test_sequence(l1);
|
||||
test_sequence(l2);
|
||||
test_sequence(l3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,284 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2006 João Abecasis
|
||||
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/invocation/invoke_procedure.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/list.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/view/single_view.hpp>
|
||||
#include <boost/fusion/view/iterator_range.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
struct object {};
|
||||
struct object_nc : boost::noncopyable {};
|
||||
|
||||
typedef int element1_type;
|
||||
typedef object element2_type;
|
||||
typedef object_nc & element3_type;
|
||||
|
||||
int element1 = 100;
|
||||
object element2 = object();
|
||||
object_nc element3;
|
||||
|
||||
class members
|
||||
{
|
||||
public:
|
||||
int data;
|
||||
|
||||
members()
|
||||
: data(20)
|
||||
{ }
|
||||
|
||||
int nullary() { return element1 = data + 1; }
|
||||
int nullary_c() const { return element1 = data + 2; }
|
||||
int unary(int & i) { return i = data + 3; }
|
||||
int unary_c(int & i) const { return i = data + 4; }
|
||||
int binary(int & i, object) { return i = data + 5; }
|
||||
int binary_c(int & i, object) const { return i = data + 6; }
|
||||
};
|
||||
|
||||
members that;
|
||||
std::auto_ptr<members> spt_that(new members);
|
||||
std::auto_ptr<members const> spt_that_c(new members);
|
||||
|
||||
fusion::single_view<members > sv_obj_ctx( that);
|
||||
fusion::single_view<members &> sv_ref_ctx( that);
|
||||
fusion::single_view<members *> sv_ptr_ctx(& that);
|
||||
fusion::single_view<members const > sv_obj_c_ctx( that);
|
||||
fusion::single_view<members const &> sv_ref_c_ctx( that);
|
||||
fusion::single_view<members const *> sv_ptr_c_ctx(& that);
|
||||
fusion::single_view<std::auto_ptr<members> const &> sv_spt_ctx(spt_that);
|
||||
fusion::single_view< std::auto_ptr<members const> const &> sv_spt_c_ctx(spt_that_c);
|
||||
|
||||
struct fobj
|
||||
{
|
||||
int operator()() { return element1 = 0; }
|
||||
int operator()() const { return element1 = 1; }
|
||||
|
||||
int operator()(int & i) { return i = 2 ; }
|
||||
int operator()(int & i) const { return i = 3; }
|
||||
|
||||
int operator()(int & i, object &) { return i = 4; }
|
||||
int operator()(int & i, object &) const { return i = 5; }
|
||||
int operator()(int & i, object const &) { return i = 6; }
|
||||
int operator()(int & i, object const &) const { return i = 7; }
|
||||
|
||||
int operator()(int & i, object &, object_nc &) { return i = 10; }
|
||||
int operator()(int & i, object &, object_nc &) const { return i = 11; }
|
||||
};
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
{
|
||||
int operator()() { return element1 = 12; }
|
||||
int operator()() const { return element1 = 13; }
|
||||
|
||||
int operator()(int & i) { return i = 14; }
|
||||
int operator()(int & i) const { return i = 15; }
|
||||
};
|
||||
|
||||
int nullary() { return element1 = 16; }
|
||||
int unary(int & i) { return i = 17; }
|
||||
int binary1(int & i, object &) { return i = 18; }
|
||||
int binary2(int & i, object const &) { return i = 19; }
|
||||
|
||||
typedef int (* func_ptr)(int &);
|
||||
typedef int (* const c_func_ptr)(int &);
|
||||
typedef int (* volatile v_func_ptr)(int &);
|
||||
typedef int (* const volatile cv_func_ptr)(int &);
|
||||
|
||||
func_ptr func_ptr1 = &unary;
|
||||
c_func_ptr func_ptr2 = &unary;
|
||||
v_func_ptr func_ptr3 = &unary;
|
||||
cv_func_ptr func_ptr4 = &unary;
|
||||
|
||||
|
||||
|
||||
#define COMPARE_EFFECT(e,t) \
|
||||
{ \
|
||||
element1 = 1234567; e; \
|
||||
int expected = element1; \
|
||||
element1 = 1234567; t; \
|
||||
BOOST_TEST(expected == element1 ); \
|
||||
}
|
||||
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<0>)
|
||||
{
|
||||
// Function Objects
|
||||
|
||||
fobj f;
|
||||
|
||||
COMPARE_EFFECT(f (), fusion::invoke_procedure(f , seq ));
|
||||
COMPARE_EFFECT(f (), fusion::invoke_procedure(f , const_(seq)));
|
||||
|
||||
// Note: The function object is taken by value, so we request the copy
|
||||
// to be const with an explicit template argument. We can also request
|
||||
// the function object to be pased by reference...
|
||||
COMPARE_EFFECT(const_(f)(), fusion::invoke_procedure<fobj const >(const_(f), seq ));
|
||||
COMPARE_EFFECT(const_(f)(), fusion::invoke_procedure<fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
fobj_nc nc_f;
|
||||
// ...and we further ensure there is no copying in this case, using a
|
||||
// noncopyable function object.
|
||||
COMPARE_EFFECT(nc_f (), fusion::invoke_procedure<fobj_nc &>(nc_f , seq ));
|
||||
COMPARE_EFFECT(nc_f (), fusion::invoke_procedure<fobj_nc &>(nc_f , const_(seq)));
|
||||
COMPARE_EFFECT(const_(nc_f)(), fusion::invoke_procedure<fobj_nc const &>(const_(nc_f), seq ));
|
||||
COMPARE_EFFECT(const_(nc_f)(), fusion::invoke_procedure<fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
|
||||
// Builtin Functions
|
||||
|
||||
// Call through ref/ptr to function
|
||||
COMPARE_EFFECT(nullary(), fusion::invoke_procedure<int (&)()>(nullary, seq));
|
||||
COMPARE_EFFECT(nullary(), fusion::invoke_procedure(& nullary, seq));
|
||||
|
||||
// Call through ptr to member function
|
||||
// Note: The non-const function members::nullary can't be invoked with
|
||||
// fusion::join(sv_obj_ctx,seq)), which is const and so is its first element
|
||||
COMPARE_EFFECT(that.nullary(), fusion::invoke_procedure(& members::nullary, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary(), fusion::invoke_procedure(& members::nullary, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary(), fusion::invoke_procedure(& members::nullary, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.nullary_c(), fusion::invoke_procedure(& members::nullary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<1>)
|
||||
{
|
||||
fobj f;
|
||||
COMPARE_EFFECT(f(element1), fusion::invoke_procedure(f , seq ));
|
||||
COMPARE_EFFECT(f(element1), fusion::invoke_procedure(f , const_(seq)));
|
||||
COMPARE_EFFECT(const_(f)(element1), fusion::invoke_procedure<fobj const >(const_(f), seq ));
|
||||
COMPARE_EFFECT(const_(f)(element1), fusion::invoke_procedure<fobj const &>(const_(f), const_(seq)));
|
||||
|
||||
fobj_nc nc_f;
|
||||
COMPARE_EFFECT(nc_f(element1), fusion::invoke_procedure<fobj_nc &>(nc_f, seq ));
|
||||
COMPARE_EFFECT(nc_f(element1), fusion::invoke_procedure<fobj_nc &>(nc_f, const_(seq)));
|
||||
COMPARE_EFFECT(const_(nc_f)(element1), fusion::invoke_procedure<fobj_nc const &>(const_(nc_f), seq ));
|
||||
COMPARE_EFFECT(const_(nc_f)(element1), fusion::invoke_procedure<fobj_nc const &>(const_(nc_f), const_(seq)));
|
||||
|
||||
COMPARE_EFFECT(unary(element1), fusion::invoke_procedure<int (&)(int &)>(unary, seq));
|
||||
COMPARE_EFFECT(func_ptr1(element1), fusion::invoke_procedure(func_ptr1, seq));
|
||||
COMPARE_EFFECT(func_ptr2(element1), fusion::invoke_procedure(func_ptr2, seq));
|
||||
COMPARE_EFFECT(func_ptr3(element1), fusion::invoke_procedure(func_ptr3, seq));
|
||||
COMPARE_EFFECT(func_ptr4(element1), fusion::invoke_procedure(func_ptr4, seq));
|
||||
|
||||
COMPARE_EFFECT(that.unary(element1), fusion::invoke_procedure(& members::unary, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary(element1), fusion::invoke_procedure(& members::unary, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary(element1), fusion::invoke_procedure(& members::unary, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.unary_c(element1), fusion::invoke_procedure(& members::unary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<2>)
|
||||
{
|
||||
fobj f;
|
||||
COMPARE_EFFECT(f (element1, element2), fusion::invoke_procedure(f , seq));
|
||||
COMPARE_EFFECT(f (element1, const_(element2)), fusion::invoke_procedure(f , const_(seq)));
|
||||
COMPARE_EFFECT(const_(f)(element1, element2), fusion::invoke_procedure<fobj const>(const_(f), seq));
|
||||
COMPARE_EFFECT(const_(f)(element1, const_(element2)), fusion::invoke_procedure<fobj const>(const_(f), const_(seq)));
|
||||
|
||||
COMPARE_EFFECT(binary1(element1, element2), fusion::invoke_procedure(binary1, seq));
|
||||
COMPARE_EFFECT(binary2(element1, element2), fusion::invoke_procedure(binary2, seq));
|
||||
|
||||
COMPARE_EFFECT(that.binary(element1,element2), fusion::invoke_procedure(& members::binary, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary(element1,element2), fusion::invoke_procedure(& members::binary, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary(element1,element2), fusion::invoke_procedure(& members::binary, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_obj_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_ref_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_ptr_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_spt_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_obj_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_ref_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_ptr_c_ctx,seq)));
|
||||
COMPARE_EFFECT(that.binary_c(element1,element2), fusion::invoke_procedure(& members::binary_c, fusion::join(sv_spt_c_ctx,seq)));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<3>)
|
||||
{
|
||||
fobj f;
|
||||
|
||||
COMPARE_EFFECT(f(element1, element2, element3), fusion::invoke_procedure(f, seq));
|
||||
COMPARE_EFFECT(const_(f)(element1, element2, element3), fusion::invoke_procedure<fobj const>(const_(f), seq));
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence(Sequence & seq)
|
||||
{
|
||||
test_sequence_n(seq, mpl::int_<fusion::result_of::size<Sequence>::value>());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef fusion::vector<> vector0;
|
||||
typedef fusion::vector<element1_type &> vector1;
|
||||
typedef fusion::vector<element1_type &, element2_type> vector2;
|
||||
typedef fusion::vector<element1_type &, element2_type, element3_type> vector3;
|
||||
|
||||
vector0 v0;
|
||||
vector1 v1(element1);
|
||||
vector2 v2(element1, element2);
|
||||
vector3 v3(element1, element2, element3);
|
||||
|
||||
test_sequence(v0);
|
||||
test_sequence(v1);
|
||||
test_sequence(v2);
|
||||
test_sequence(v3);
|
||||
|
||||
typedef fusion::list<> list0;
|
||||
typedef fusion::list<element1_type &> list1;
|
||||
typedef fusion::list<element1_type &, element2_type> list2;
|
||||
typedef fusion::list<element1_type &, element2_type, element3_type> list3;
|
||||
|
||||
list0 l0;
|
||||
list1 l1(element1);
|
||||
list2 l2(element1, element2);
|
||||
list3 l3(element1, element2, element3);
|
||||
|
||||
test_sequence(l0);
|
||||
test_sequence(l1);
|
||||
test_sequence(l2);
|
||||
test_sequence(l3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,85 +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_fused.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
using boost::cref;
|
||||
using boost::ref;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
typedef int result_type;
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fusion::vector<int,char> lv_vec(1,'\004');
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_fused< test_func<> >::type fused_func
|
||||
= fusion::make_fused(f);
|
||||
|
||||
BOOST_TEST(fused_func(lv_vec) == 1);
|
||||
BOOST_TEST(const_(fused_func)(lv_vec) == 0);
|
||||
BOOST_TEST(fusion::make_fused(const_(f))(lv_vec) == 1);
|
||||
BOOST_TEST(fusion::make_fused(ref(f_nc))(lv_vec) == 1);
|
||||
BOOST_TEST(fusion::make_fused(cref(f_nc))(lv_vec) == 0);
|
||||
|
||||
BOOST_TEST(fused_func(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(const_(fused_func)(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fusion::make_fused(const_(f))(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fusion::make_fused(ref(f_nc))(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fusion::make_fused(cref(f_nc))(fusion::make_vector(2,'\003')) == 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,95 +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_fused_function_object.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
using boost::cref;
|
||||
using boost::ref;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
struct result
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template<class Self, typename T0, typename T1>
|
||||
struct result< Self(T0, T1) >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fusion::vector<int,char> lv_vec(1,'\004');
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_fused_function_object< test_func<> >::type fused_func
|
||||
= fusion::make_fused_function_object(f);
|
||||
|
||||
BOOST_TEST(fused_func(lv_vec) == 1);
|
||||
BOOST_TEST(const_(fused_func)(lv_vec) == 0);
|
||||
BOOST_TEST(fusion::make_fused_function_object(const_(f))(lv_vec) == 1);
|
||||
BOOST_TEST(fusion::make_fused_function_object(ref(f_nc))(lv_vec) == 1);
|
||||
BOOST_TEST(fusion::make_fused_function_object(cref(f_nc))(lv_vec) == 0);
|
||||
|
||||
BOOST_TEST(fused_func(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(const_(fused_func)(fusion::make_vector(2,'\003')) == 0);
|
||||
BOOST_TEST(fusion::make_fused_function_object(const_(f))(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fusion::make_fused_function_object(ref(f_nc))(fusion::make_vector(2,'\003')) == 1);
|
||||
BOOST_TEST(fusion::make_fused_function_object(cref(f_nc))(fusion::make_vector(2,'\003')) == 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,91 +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_fused_procedure.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/blank.hpp>
|
||||
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
using boost::noncopyable;
|
||||
using boost::cref;
|
||||
using boost::ref;
|
||||
|
||||
int effect;
|
||||
|
||||
#define CHECK_EFFECT(t,e) \
|
||||
{ \
|
||||
effect = 1234567; t; \
|
||||
BOOST_TEST(effect == e); \
|
||||
}
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y) const
|
||||
{
|
||||
return effect = 1+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 const & x, T1 const & y)
|
||||
{
|
||||
return effect = 2+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y) const
|
||||
{
|
||||
return effect = 3+x-y;
|
||||
}
|
||||
|
||||
template <typename T0, typename T1>
|
||||
int operator()(T0 & x, T1 & y)
|
||||
{
|
||||
return effect = 4+x-y;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T const & const_(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
fusion::vector<int,char> lv_vec(1,'\004');
|
||||
test_func<> f;
|
||||
test_func<noncopyable> f_nc;
|
||||
|
||||
fusion::result_of::make_fused_procedure< test_func<> >::type fused_func
|
||||
= fusion::make_fused_procedure(f);
|
||||
|
||||
CHECK_EFFECT(fused_func(lv_vec), 1);
|
||||
CHECK_EFFECT(const_(fused_func)(lv_vec), 0);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(const_(f))(lv_vec), 1);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(ref(f_nc))(lv_vec), 1);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(cref(f_nc))(lv_vec), 0);
|
||||
|
||||
CHECK_EFFECT(fused_func(fusion::make_vector(2,'\003')), 1);
|
||||
CHECK_EFFECT(const_(fused_func)(fusion::make_vector(2,'\003')), 0);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(const_(f))(fusion::make_vector(2,'\003')), 1);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(ref(f_nc))(fusion::make_vector(2,'\003')), 1);
|
||||
CHECK_EFFECT(fusion::make_fused_procedure(cref(f_nc))(fusion::make_vector(2,'\003')), 0);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -1,166 +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_typed.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/blank.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <boost/utility/result_of.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 mpl::placeholders::_;
|
||||
|
||||
using boost::noncopyable;
|
||||
|
||||
typedef fusion::vector<> types0;
|
||||
typedef fusion::vector<long &> types1;
|
||||
typedef fusion::vector<long &,int,char> types3;
|
||||
|
||||
template <class Base = boost::blank>
|
||||
struct test_func
|
||||
: Base
|
||||
{
|
||||
template<typename T>
|
||||
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;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
long operator()(T & elem, long value) const
|
||||
{
|
||||
elem += sizeof(T);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void result_type_tests()
|
||||
{
|
||||
using boost::is_same;
|
||||
|
||||
typedef fusion::unfused_typed< test_func<>, types0 > t0;
|
||||
BOOST_TEST(( is_same< boost::result_of< t0 () >::type, long >::value ));
|
||||
typedef fusion::unfused_typed< test_func<>, types1 > t1;
|
||||
BOOST_TEST(( is_same< boost::result_of< t1 (int) >::type, long >::value ));
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1400
|
||||
# define BOOST_TEST_NO_VC71(cond) (void)((cond)?0:1)
|
||||
#else
|
||||
# define BOOST_TEST_NO_VC71(cond) BOOST_TEST(cond)
|
||||
#endif
|
||||
|
||||
void nullary_tests()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_typed< test_func<>, types0 > unfused_func;
|
||||
fusion::unfused_typed< test_func<noncopyable> &, types0 > unfused_func_ref(f);
|
||||
fusion::unfused_typed< test_func<> const, types0 > unfused_func_c;
|
||||
fusion::unfused_typed< test_func<>, types0 > const unfused_func_c2;
|
||||
fusion::unfused_typed< test_func<noncopyable> const &, types0 > 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);
|
||||
}
|
||||
|
||||
void unary_tests()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_typed< test_func<>, types1 > unfused_func;
|
||||
fusion::unfused_typed< test_func<noncopyable> &, types1 > unfused_func_ref(f);
|
||||
fusion::unfused_typed< test_func<> const, types1 > unfused_func_c;
|
||||
fusion::unfused_typed< test_func<>, types1 > const unfused_func_c2;
|
||||
fusion::unfused_typed< test_func<noncopyable> const &, types1 > unfused_func_c_ref(f);
|
||||
|
||||
long lvalue = 1;
|
||||
BOOST_TEST_NO_VC71(unfused_func(lvalue) == 100);
|
||||
BOOST_TEST(lvalue == 1 + 1*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_ref(lvalue) == 100);
|
||||
BOOST_TEST(lvalue == 1 + 2*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c(lvalue) == 0);
|
||||
BOOST_TEST(lvalue == 1 + 3*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c2(lvalue) == 0);
|
||||
BOOST_TEST(lvalue == 1 + 4*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c_ref(lvalue) == 0);
|
||||
BOOST_TEST(lvalue == 1 + 5*sizeof(lvalue));
|
||||
}
|
||||
|
||||
void ternary_tests()
|
||||
{
|
||||
test_func<noncopyable> f;
|
||||
fusion::unfused_typed< test_func<>, types3 > unfused_func;
|
||||
fusion::unfused_typed< test_func<noncopyable> &, types3 > unfused_func_ref(f);
|
||||
fusion::unfused_typed< test_func<> const, types3 > unfused_func_c;
|
||||
fusion::unfused_typed< test_func<>, types3 > const unfused_func_c2;
|
||||
fusion::unfused_typed< test_func<noncopyable> const &, types3 > unfused_func_c_ref(f);
|
||||
|
||||
long lvalue = 1;
|
||||
static const long expected = 2*sizeof(int) + 7*sizeof(char);
|
||||
BOOST_TEST_NO_VC71(unfused_func(lvalue,2,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 1 + 1*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_ref(lvalue,2,'\007') == 100 + expected);
|
||||
BOOST_TEST(lvalue == 1 + 2*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c(lvalue,2,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 1 + 3*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c2(lvalue,2,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 1 + 4*sizeof(lvalue));
|
||||
BOOST_TEST(unfused_func_c_ref(lvalue,2,'\007') == 0 + expected);
|
||||
BOOST_TEST(lvalue == 1 + 5*sizeof(lvalue));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
result_type_tests();
|
||||
nullary_tests();
|
||||
unary_tests();
|
||||
ternary_tests();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 Joel de Guzman
|
||||
Copyright (c) 2005-2007 Dan Marsden
|
||||
|
||||
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/adapted/struct/adapt_assoc_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace ns
|
||||
{
|
||||
struct x_member;
|
||||
struct y_member;
|
||||
struct z_member;
|
||||
|
||||
struct point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
|
||||
ns::point,
|
||||
(int, x, ns::x_member)
|
||||
(int, y, ns::y_member)
|
||||
)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
|
||||
ns::point p = {123, 456};
|
||||
|
||||
std::cout << at_c<0>(p) << std::endl;
|
||||
std::cout << at_c<1>(p) << std::endl;
|
||||
std::cout << p << std::endl;
|
||||
BOOST_TEST(p == make_vector(123, 456));
|
||||
|
||||
at_c<0>(p) = 6;
|
||||
at_c<1>(p) = 9;
|
||||
BOOST_TEST(p == make_vector(6, 9));
|
||||
|
||||
BOOST_STATIC_ASSERT(result_of::size<ns::point>::value == 2);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<ns::point>::value);
|
||||
|
||||
BOOST_TEST(front(p) == 6);
|
||||
BOOST_TEST(back(p) == 9);
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<int, float> v1(4, 2);
|
||||
ns::point v2 = {5, 3};
|
||||
fusion::vector<long, double> v3(5, 4);
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p = {5, 3};
|
||||
fusion::vector<int, short> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p = {5, 3};
|
||||
fusion::list<int, short> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
{
|
||||
// assoc stuff
|
||||
BOOST_MPL_ASSERT((fusion::result_of::has_key<ns::point, ns::x_member>));
|
||||
BOOST_MPL_ASSERT((fusion::result_of::has_key<ns::point, ns::y_member>));
|
||||
BOOST_MPL_ASSERT((mpl::not_<fusion::result_of::has_key<ns::point, ns::z_member> >));
|
||||
|
||||
BOOST_MPL_ASSERT((is_same<fusion::result_of::value_at_key<ns::point, ns::x_member>::type, int>));
|
||||
BOOST_MPL_ASSERT((is_same<fusion::result_of::value_at_key<ns::point, ns::y_member>::type, int>));
|
||||
|
||||
ns::point p = {5, 3};
|
||||
|
||||
BOOST_TEST(at_key<ns::x_member>(p) == 5);
|
||||
BOOST_TEST(at_key<ns::y_member>(p) == 3);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,106 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace ns
|
||||
{
|
||||
struct point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
ns::point,
|
||||
(int, x)
|
||||
(int, y)
|
||||
)
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<ns::point>));
|
||||
ns::point p = {123, 456};
|
||||
|
||||
std::cout << at_c<0>(p) << std::endl;
|
||||
std::cout << at_c<1>(p) << std::endl;
|
||||
std::cout << p << std::endl;
|
||||
BOOST_TEST(p == make_vector(123, 456));
|
||||
|
||||
at_c<0>(p) = 6;
|
||||
at_c<1>(p) = 9;
|
||||
BOOST_TEST(p == make_vector(6, 9));
|
||||
|
||||
BOOST_STATIC_ASSERT(result_of::size<ns::point>::value == 2);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<ns::point>::value);
|
||||
|
||||
BOOST_TEST(front(p) == 6);
|
||||
BOOST_TEST(back(p) == 9);
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<int, float> v1(4, 2);
|
||||
ns::point v2 = {5, 3};
|
||||
fusion::vector<long, double> v3(5, 4);
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to vector
|
||||
ns::point p = {5, 3};
|
||||
fusion::vector<int, short> v(p);
|
||||
v = p;
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from ns::point to list
|
||||
ns::point p = {5, 3};
|
||||
fusion::list<int, short> l(p);
|
||||
l = p;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2005-2006 Dan Marsden
|
||||
|
||||
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/adapted/array.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
typedef boost::array<int,3> array_type;
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<array_type>));
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<array_type>));
|
||||
|
||||
array_type arr = {{1,2,3}};
|
||||
|
||||
BOOST_TEST(*begin(arr) == 1);
|
||||
BOOST_TEST(*next(begin(arr)) == 2);
|
||||
BOOST_TEST(*advance_c<2>(begin(arr)) == 3);
|
||||
BOOST_TEST(prior(next(begin(arr))) == begin(arr));
|
||||
BOOST_TEST(*prior(end(arr)) == 3);
|
||||
BOOST_TEST(at_c<2>(arr) == 3);
|
||||
BOOST_TEST(size(arr) == 3);
|
||||
BOOST_TEST(distance(begin(arr), end(arr)) == 3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/container/list/convert.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
vector0 empty;
|
||||
std::cout << as_list(make_vector(1, 1.23, "harru")) << std::endl;
|
||||
std::cout << as_list(push_back(empty, 999)) << std::endl;
|
||||
|
||||
BOOST_TEST(as_list(make_vector(1, 1.23, "harru")) == make_vector(1, 1.23, std::string("harru")));
|
||||
BOOST_TEST(as_list(push_back(empty, 999)) == push_back(empty, 999));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << as_list(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
|
||||
BOOST_TEST((as_list(mpl::vector_c<int, 1, 2, 3, 4, 5>())
|
||||
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
|
||||
}
|
||||
|
||||
{
|
||||
// test conversion
|
||||
list<int, std::string> l(make_vector(123, "harru"));
|
||||
BOOST_TEST(l == make_vector(123, "harru"));
|
||||
l = (make_vector(235, "hola")); // test assign
|
||||
BOOST_TEST(l == make_vector(235, "hola"));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/container/map/convert.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
vector0 empty;
|
||||
std::cout << as_map(make_list(make_pair<int>('X'), make_pair<double>("Men"))) << std::endl;
|
||||
std::cout << as_map(push_back(empty, make_pair<int>(999))) << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef pair<int, char> p1;
|
||||
typedef pair<double, std::string> p2;
|
||||
result_of::as_map<list<p1, p2> >::type map(make_pair<int>('X'), make_pair<double>("Men"));
|
||||
std::cout << at_key<int>(map) << std::endl;
|
||||
std::cout << at_key<double>(map) << std::endl;
|
||||
BOOST_TEST(at_key<int>(map) == 'X');
|
||||
BOOST_TEST(at_key<double>(map) == "Men");
|
||||
}
|
||||
|
||||
{
|
||||
// test conversion
|
||||
typedef map<
|
||||
pair<int, char>
|
||||
, pair<double, std::string> >
|
||||
map_type;
|
||||
|
||||
map_type m(make_vector(make_pair<int>('X'), make_pair<double>("Men")));
|
||||
BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
|
||||
m = (make_vector(make_pair<int>('X'), make_pair<double>("Men"))); // test assign
|
||||
BOOST_TEST(as_vector(m) == make_vector(make_pair<int>('X'), make_pair<double>("Men")));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/container/set/convert.hpp>
|
||||
#include <boost/fusion/container/list/convert.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
vector0 empty;
|
||||
std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl;
|
||||
std::cout << as_set(push_back(empty, 999)) << std::endl;
|
||||
|
||||
BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru")))
|
||||
== make_list(1, 1.23, std::string("harru")));
|
||||
BOOST_TEST(as_list(as_set(push_back(empty, 999)))
|
||||
== push_back(empty, 999));
|
||||
}
|
||||
|
||||
{
|
||||
result_of::as_set<list<int, double, std::string> >::type set(1, 1.23, "harru");
|
||||
std::cout << at_key<int>(set) << std::endl;
|
||||
BOOST_TEST(at_key<int>(set) == 1);
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
|
||||
BOOST_TEST((as_list(as_set(mpl::vector_c<int, 1, 2, 3, 4, 5>()))
|
||||
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
|
||||
}
|
||||
|
||||
{
|
||||
// test conversion
|
||||
set<int, std::string> s(make_vector(123, "harru"));
|
||||
BOOST_TEST(as_vector(s) == make_vector(123, "harru"));
|
||||
s = (make_vector(235, "hola")); // test assign
|
||||
BOOST_TEST(as_vector(s) == make_vector(235, "hola"));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/push_back.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
vector0 empty;
|
||||
std::cout << as_vector(make_list(1, 1.23, "harru")) << std::endl;
|
||||
std::cout << as_vector(push_back(empty, 999)) << std::endl;
|
||||
|
||||
BOOST_TEST(as_vector(make_list(1, 1.23, "harru")) == make_list(1, 1.23, std::string("harru")));
|
||||
BOOST_TEST(as_vector(push_back(empty, 999)) == push_back(empty, 999));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>()) << std::endl;
|
||||
BOOST_TEST((as_vector(mpl::vector_c<int, 1, 2, 3, 4, 5>())
|
||||
== mpl::vector_c<int, 1, 2, 3, 4, 5>()));
|
||||
}
|
||||
|
||||
{
|
||||
// test conversion
|
||||
vector<int, std::string> v(make_list(123, "harru"));
|
||||
BOOST_TEST(v == make_list(123, "harru"));
|
||||
v = (make_list(235, "hola")); // test assign
|
||||
BOOST_TEST(v == make_list(235, "hola"));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/deque/deque.hpp>
|
||||
#include <boost/fusion/container/deque/back_extended_deque.hpp>
|
||||
#include <boost/fusion/sequence/comparison.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
typedef deque<int, char> initial_deque_type;
|
||||
initial_deque_type initial_deque(1, 'a');
|
||||
typedef back_extended_deque<initial_deque_type, long> extended_type;
|
||||
extended_type extended(initial_deque, 101L);
|
||||
|
||||
BOOST_TEST(size(extended) == 3);
|
||||
BOOST_TEST(extended == make_vector(1, 'a', 101L));
|
||||
BOOST_TEST(*begin(extended) == 1);
|
||||
BOOST_TEST(*next(begin(extended)) == 'a');
|
||||
BOOST_TEST(*prior(end(extended)) == 101L);
|
||||
BOOST_TEST(distance(begin(extended), end(extended)) == 3);
|
||||
BOOST_TEST(*advance_c<2>(begin(extended)) == 101L);
|
||||
}
|
||||
{
|
||||
namespace mpl = boost::mpl;
|
||||
typedef deque<int, char> initial_deque_type;
|
||||
typedef back_extended_deque<initial_deque_type, long> extended_type;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 0>::type, int>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 1>::type, char>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 2>::type, long>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, int>));
|
||||
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<3> >));
|
||||
}
|
||||
{
|
||||
char ch('a');
|
||||
long l(101L);
|
||||
int i(1);
|
||||
typedef deque<int&, char&> initial_deque_type;
|
||||
initial_deque_type initial_deque(i, ch);
|
||||
typedef back_extended_deque<initial_deque_type, long&> extended_type;
|
||||
extended_type extended(initial_deque, l);
|
||||
BOOST_TEST(extended == make_vector(1, 'a', 101L));
|
||||
|
||||
char ch2('b');
|
||||
long l2(202L);
|
||||
int i2(2);
|
||||
extended_type extended2(initial_deque_type(i2, ch2), l2);
|
||||
|
||||
extended = extended2;
|
||||
|
||||
BOOST_TEST(extended == make_vector(2, 'b', 202L));
|
||||
|
||||
BOOST_TEST(i == i2);
|
||||
BOOST_TEST(ch == ch2);
|
||||
BOOST_TEST(l == l2);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/boost_tuple.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
typedef boost::tuple<int, std::string> tuple_type;
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<tuple_type>));
|
||||
tuple_type t(123, "Hola!!!");
|
||||
|
||||
std::cout << at_c<0>(t) << std::endl;
|
||||
std::cout << at_c<1>(t) << std::endl;
|
||||
std::cout << t << std::endl;
|
||||
BOOST_TEST(t == make_vector(123, "Hola!!!"));
|
||||
|
||||
at_c<0>(t) = 6;
|
||||
at_c<1>(t) = "mama mia";
|
||||
BOOST_TEST(t == make_vector(6, "mama mia"));
|
||||
|
||||
BOOST_STATIC_ASSERT(result_of::size<tuple_type>::value == 2);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<tuple_type>::value);
|
||||
|
||||
BOOST_TEST(front(t) == 6);
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<int, float> v1(4, 3.3f);
|
||||
boost::tuple<short, float> v2(5, 3.3f);
|
||||
fusion::vector<long, double> v3(5, 4.4);
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from boost tuple to vector
|
||||
fusion::vector<int, std::string> v(tuples::make_tuple(123, "Hola!!!"));
|
||||
v = tuples::make_tuple(123, "Hola!!!");
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from boost tuple to list
|
||||
fusion::list<int, std::string> l(tuples::make_tuple(123, "Hola!!!"));
|
||||
l = tuples::make_tuple(123, "Hola!!!");
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/comparison.hpp>
|
||||
|
||||
void
|
||||
equality_test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
FUSION_SEQUENCE<int, char> v1(5, 'a');
|
||||
FUSION_SEQUENCE<int, char> v2(5, 'a');
|
||||
BOOST_TEST(v1 == v2);
|
||||
|
||||
FUSION_SEQUENCE<int, char> v3(5, 'b');
|
||||
FUSION_SEQUENCE<int, char> t4(2, 'a');
|
||||
BOOST_TEST(v1 != v3);
|
||||
BOOST_TEST(v1 != t4);
|
||||
BOOST_TEST(!(v1 != v2));
|
||||
|
||||
FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
|
||||
BOOST_TEST(v1 != v5);
|
||||
BOOST_TEST(!(v1 == v5));
|
||||
BOOST_TEST(v5 != v1);
|
||||
BOOST_TEST(!(v5 == v1));
|
||||
}
|
||||
|
||||
void
|
||||
ordering_test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
FUSION_SEQUENCE<int, float> v1(4, 3.3f);
|
||||
FUSION_SEQUENCE<short, float> v2(5, 3.3f);
|
||||
FUSION_SEQUENCE<long, double> v3(5, 4.4);
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
|
||||
#if defined(FUSION_TEST_FAIL)
|
||||
FUSION_SEQUENCE<int, char, bool> v5(5, 'a', true);
|
||||
v1 >= v5;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,87 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005 Joel de Guzman
|
||||
Copyright (c) 2005 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 <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/list/cons.hpp>
|
||||
#include <boost/fusion/container/generation/make_cons.hpp>
|
||||
#include <boost/fusion/container/generation/cons_tie.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/filter_if.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/lambda.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::is_same;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing cons
|
||||
|
||||
{
|
||||
std::string hello("hello");
|
||||
cons<int, cons<std::string> > ns =
|
||||
make_cons(1, make_cons(hello));
|
||||
|
||||
BOOST_TEST((*begin(ns) == 1));
|
||||
BOOST_TEST((*next(begin(ns)) == hello));
|
||||
|
||||
*begin(ns) += 1;
|
||||
*next(begin(ns)) += ' ';
|
||||
|
||||
BOOST_TEST((*begin(ns) == 2));
|
||||
BOOST_TEST((*next(begin(ns)) == hello + ' '));
|
||||
|
||||
for_each(ns, boost::lambda::_1 += ' ');
|
||||
|
||||
BOOST_TEST((*begin(ns) == 2 + ' '));
|
||||
BOOST_TEST((*next(begin(ns)) == hello + ' ' + ' '));
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(
|
||||
make_cons("hello") == make_vector(std::string("hello"))
|
||||
);
|
||||
|
||||
BOOST_TEST(
|
||||
make_cons(123, make_cons("hello")) ==
|
||||
make_vector(123, std::string("hello"))
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, float> t(1, 1.1f);
|
||||
cons<int, cons<float> > nf =
|
||||
make_cons(1, make_cons(1.1f));
|
||||
|
||||
BOOST_TEST((t == nf));
|
||||
BOOST_TEST((vector<int>(1) == filter_if<is_same<boost::mpl::_, int> >(nf)));
|
||||
|
||||
std::cout << nf << std::endl;
|
||||
std::cout << filter_if<is_same<boost::mpl::_, int> >(nf) << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
int i = 3;
|
||||
cons<int&> tie(cons_tie(i));
|
||||
BOOST_TEST((*begin(tie) == 3));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/container/list/cons.hpp>
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
// something to prevent warnings for unused variables
|
||||
template<class T> void dummy(const T&) {}
|
||||
|
||||
// no public default constructor
|
||||
class foo
|
||||
{
|
||||
public:
|
||||
|
||||
explicit foo(int v) : val(v) {}
|
||||
|
||||
bool operator==(const foo& other) const
|
||||
{
|
||||
return val == other.val;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
foo() {}
|
||||
int val;
|
||||
};
|
||||
|
||||
// another class without a public default constructor
|
||||
class no_def_constructor
|
||||
{
|
||||
no_def_constructor() {}
|
||||
|
||||
public:
|
||||
|
||||
no_def_constructor(std::string) {}
|
||||
};
|
||||
}
|
||||
|
||||
inline void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace test_detail;
|
||||
|
||||
nil empty;
|
||||
|
||||
FUSION_SEQUENCE<> empty0;
|
||||
|
||||
FUSION_SEQUENCE<> empty1(empty);
|
||||
|
||||
FUSION_SEQUENCE<int> t1;
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == int());
|
||||
|
||||
FUSION_SEQUENCE<float> t2(5.5f);
|
||||
BOOST_TEST(FUSION_AT<0>(t2) > 5.4f && FUSION_AT<0>(t2) < 5.6f);
|
||||
|
||||
FUSION_SEQUENCE<foo> t3(foo(12));
|
||||
BOOST_TEST(FUSION_AT<0>(t3) == foo(12));
|
||||
|
||||
FUSION_SEQUENCE<double> t4(t2);
|
||||
BOOST_TEST(FUSION_AT<0>(t4) > 5.4 && FUSION_AT<0>(t4) < 5.6);
|
||||
|
||||
FUSION_SEQUENCE<int, float> t5;
|
||||
BOOST_TEST(FUSION_AT<0>(t5) == int());
|
||||
BOOST_TEST(FUSION_AT<1>(t5) == float());
|
||||
|
||||
FUSION_SEQUENCE<int, float> t6(12, 5.5f);
|
||||
BOOST_TEST(FUSION_AT<0>(t6) == 12);
|
||||
BOOST_TEST(FUSION_AT<1>(t6) > 5.4f && FUSION_AT<1>(t6) < 5.6f);
|
||||
|
||||
FUSION_SEQUENCE<int, float> t7(t6);
|
||||
BOOST_TEST(FUSION_AT<0>(t7) == 12);
|
||||
BOOST_TEST(FUSION_AT<1>(t7) > 5.4f && FUSION_AT<1>(t7) < 5.6f);
|
||||
|
||||
FUSION_SEQUENCE<long, double> t8(t6);
|
||||
BOOST_TEST(FUSION_AT<0>(t8) == 12);
|
||||
BOOST_TEST(FUSION_AT<1>(t8) > 5.4f && FUSION_AT<1>(t8) < 5.6f);
|
||||
|
||||
dummy
|
||||
(
|
||||
FUSION_SEQUENCE<no_def_constructor, no_def_constructor, no_def_constructor>(
|
||||
std::string("Jaba"), // ok, since the default
|
||||
std::string("Daba"), // constructor is not used
|
||||
std::string("Doo")
|
||||
)
|
||||
);
|
||||
|
||||
dummy(FUSION_SEQUENCE<int, double>());
|
||||
dummy(FUSION_SEQUENCE<int, double>(1,3.14));
|
||||
|
||||
#if defined(FUSION_TEST_FAIL)
|
||||
dummy(FUSION_SEQUENCE<double&>()); // should fail, no defaults for references
|
||||
dummy(FUSION_SEQUENCE<const double&>()); // likewise
|
||||
#endif
|
||||
|
||||
{
|
||||
double dd = 5;
|
||||
dummy(FUSION_SEQUENCE<double&>(dd)); // ok
|
||||
dummy(FUSION_SEQUENCE<const double&>(dd+3.14)); // ok, but dangerous
|
||||
}
|
||||
|
||||
#if defined(FUSION_TEST_FAIL)
|
||||
dummy(FUSION_SEQUENCE<double&>(dd+3.14)); // should fail,
|
||||
// temporary to non-const reference
|
||||
#endif
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/mpl/insert_range.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
|
||||
#if !defined(FUSION_MAKE)
|
||||
#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE)
|
||||
#endif
|
||||
|
||||
#if !defined(FUSION_TIE)
|
||||
#define FUSION_TIE BOOST_PP_CAT(FUSION_SEQUENCE, _tie)
|
||||
#endif
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
// classes with different kinds of conversions
|
||||
class AA {};
|
||||
class BB : public AA {};
|
||||
struct CC { CC() {} CC(const BB&) {} };
|
||||
struct DD { operator CC() const { return CC(); }; };
|
||||
}
|
||||
|
||||
boost::fusion::FUSION_SEQUENCE<double, double, double, double>
|
||||
foo(int i)
|
||||
{
|
||||
return boost::fusion::FUSION_MAKE(i, i+1, i+2, i+3);
|
||||
}
|
||||
|
||||
void test_mpl()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
typedef FUSION_SEQUENCE<int, char> seq;
|
||||
|
||||
typedef
|
||||
boost::mpl::insert_range<
|
||||
boost::mpl::vector<>
|
||||
, boost::mpl::end< boost::mpl::vector<> >::type
|
||||
, seq
|
||||
>::type
|
||||
sequence;
|
||||
|
||||
typedef boost::mpl::equal<sequence, boost::mpl::vector<int, char> > equal;
|
||||
BOOST_STATIC_ASSERT(equal::value);
|
||||
}
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace test_detail;
|
||||
|
||||
FUSION_SEQUENCE<int, char> t1(4, 'a');
|
||||
FUSION_SEQUENCE<int, char> t2(5, 'b');
|
||||
t2 = t1;
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == FUSION_AT<0>(t2));
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t2));
|
||||
|
||||
FUSION_SEQUENCE<long, std::string> t3(2, "a");
|
||||
t3 = t1;
|
||||
BOOST_TEST((double)FUSION_AT<0>(t1) == FUSION_AT<0>(t3));
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == FUSION_AT<1>(t3)[0]);
|
||||
|
||||
// testing copy and assignment with implicit conversions
|
||||
// between elements testing tie
|
||||
|
||||
FUSION_SEQUENCE<char, BB*, BB, DD> t;
|
||||
FUSION_SEQUENCE<int, AA*, CC, CC> a(t);
|
||||
a = t;
|
||||
|
||||
int i; char c; double d;
|
||||
FUSION_TIE(i, c, d) = FUSION_MAKE(1, 'a', 5.5);
|
||||
|
||||
BOOST_TEST(i==1);
|
||||
BOOST_TEST(c=='a');
|
||||
BOOST_TEST(d>5.4 && d<5.6);
|
||||
|
||||
// returning a tuple with conversion
|
||||
foo(2);
|
||||
|
||||
test_mpl();
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 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/support/deduce_sequence.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/mpl/equal.hpp>
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
using boost::is_same;
|
||||
using boost::reference_wrapper;
|
||||
using boost::fusion::traits::deduce;
|
||||
using boost::fusion::traits::deduce_sequence;
|
||||
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
template <class Args>
|
||||
struct test_seq_ctor
|
||||
{
|
||||
typename deduce_sequence<Args>::type fsq_args;
|
||||
|
||||
test_seq_ctor(Args const & args)
|
||||
: fsq_args(args)
|
||||
{ }
|
||||
};
|
||||
|
||||
#define TEST_SAME_TYPE(a,b) BOOST_TEST(( is_same< a, b >::value ))
|
||||
#define TEST_SAME_ELEMENTS(a,b) BOOST_TEST(( boost::mpl::equal< a, b >::type::value ))
|
||||
|
||||
typedef fusion::vector<int, int const, int &, int const &> args1;
|
||||
typedef fusion::vector<int, int, int &, int> storable1;
|
||||
template struct test_seq_ctor<args1>;
|
||||
|
||||
typedef fusion::vector< reference_wrapper<int> &, reference_wrapper<int const> &,
|
||||
reference_wrapper<int> const &, reference_wrapper<int const> const & > args2;
|
||||
typedef fusion::vector<int &, int const &, int &, int const &> storable2;
|
||||
template struct test_seq_ctor<args2>;
|
||||
|
||||
|
||||
typedef fusion::vector<int *, int const *, int const * const, int const * &, int const * const &> args3;
|
||||
typedef fusion::vector<int *, int const *, int const *, int const * &, int const * > storable3;
|
||||
template struct test_seq_ctor<args3>;
|
||||
|
||||
typedef fusion::vector<int(&)[2], int const(&)[2]> args4;
|
||||
typedef args4 storable4;
|
||||
template struct test_seq_ctor<args4>;
|
||||
|
||||
int main()
|
||||
{
|
||||
TEST_SAME_TYPE(deduce<int &>::type, int &);
|
||||
TEST_SAME_TYPE(deduce<int volatile &>::type, int volatile &);
|
||||
|
||||
TEST_SAME_TYPE(deduce<int>::type, int);
|
||||
TEST_SAME_TYPE(deduce<int const &>::type, int);
|
||||
TEST_SAME_TYPE(deduce<int const volatile &>::type, int);
|
||||
|
||||
TEST_SAME_TYPE(deduce< reference_wrapper<int> & >::type, int &);
|
||||
TEST_SAME_TYPE(deduce< reference_wrapper<int const> & >::type, int const &);
|
||||
TEST_SAME_TYPE(deduce< reference_wrapper<int> const & >::type, int &);
|
||||
TEST_SAME_TYPE(deduce< reference_wrapper<int const> const & >::type, int const &);
|
||||
|
||||
TEST_SAME_TYPE(deduce< int(&)[2] >::type, int(&)[2]);
|
||||
TEST_SAME_TYPE(deduce< int const (&)[2] >::type, int const (&)[2]);
|
||||
TEST_SAME_TYPE(deduce< int volatile (&)[2] >::type, int volatile (&)[2]);
|
||||
TEST_SAME_TYPE(deduce< int const volatile (&)[2] >::type, int const volatile (&)[2]);
|
||||
|
||||
TEST_SAME_ELEMENTS(deduce_sequence<args1>::type,storable1);
|
||||
TEST_SAME_ELEMENTS(deduce_sequence<args2>::type,storable2);
|
||||
TEST_SAME_ELEMENTS(deduce_sequence<args3>::type,storable3);
|
||||
TEST_SAME_ELEMENTS(deduce_sequence<args4>::type,storable4);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "comparison.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
equality_test();
|
||||
ordering_test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "construction.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
#include <boost/fusion/container/generation/make_deque.hpp>
|
||||
#include <boost/fusion/container/generation/deque_tie.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "copy.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#define FUSION_TRAVERSAL_TAG bidirectional_traversal_tag
|
||||
#include "./iterator.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
#include <boost/fusion/container/generation/make_deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "make.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
#include <boost/fusion/container/deque/convert.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "misc.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "mutate.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
#include <boost/fusion/container/generation/deque_tie.hpp>
|
||||
#include <boost/fusion/container/generation/ignore.hpp>
|
||||
#include <boost/fusion/container/generation/make_deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "tie.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/fusion/container/deque/deque.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE deque
|
||||
#include "value_at.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,146 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
|
||||
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/view/ext_/segmented_iterator_range.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <sstream>
|
||||
|
||||
struct ostream_fun
|
||||
{
|
||||
ostream_fun(std::ostream &sout)
|
||||
: sout_(sout)
|
||||
{}
|
||||
template<typename T>
|
||||
void operator ()(T const &t) const
|
||||
{
|
||||
sout_ << t << ' ';
|
||||
}
|
||||
private:
|
||||
std::ostream & sout_;
|
||||
};
|
||||
|
||||
template<typename Tree>
|
||||
void
|
||||
process_tree(Tree const &tree)
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace fusion;
|
||||
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 iterator_range<short_iter, float_iter> slice_t;
|
||||
BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value);
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = find_if_s<is_same<_,short> >(tree);
|
||||
float_iter fi = find_if_s<is_same<_,float> >(tree);
|
||||
|
||||
// If you put them in an iterator range, the range
|
||||
// is automatically a segmented data structure.
|
||||
slice_t slice(si, fi);
|
||||
|
||||
std::stringstream sout;
|
||||
fusion::for_each_s(slice, ostream_fun(sout));
|
||||
BOOST_TEST((sout.str() == "100 e f 0 B "));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type vec(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
typedef vector_iterator<vector_type, 1> i1t;
|
||||
typedef vector_iterator<vector_type, 3> i3t;
|
||||
|
||||
i1t i1(vec);
|
||||
i3t i3(vec);
|
||||
|
||||
typedef iterator_range<i1t, i3t> slice_t;
|
||||
slice_t slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST((slice == make_vector('x', 3.3)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_iterator<vector_type, 0> i1t;
|
||||
typedef vector_iterator<vector_type, 0> i3t;
|
||||
|
||||
i1t i1(vec);
|
||||
i3t i3(vec);
|
||||
|
||||
typedef iterator_range<i1t, i3t> slice_t;
|
||||
slice_t slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST(slice == make_vector());
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
|
||||
typedef boost::mpl::begin<mpl_vec>::type it0;
|
||||
typedef boost::mpl::next<it0>::type it1;
|
||||
typedef boost::mpl::next<it1>::type it2;
|
||||
typedef boost::mpl::next<it2>::type it3;
|
||||
|
||||
it1 f;
|
||||
it3 l;
|
||||
|
||||
typedef iterator_range<it1, it3> slice_t;
|
||||
slice_t slice(f, l);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST((slice == make_vector(3, 4)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
|
||||
}
|
||||
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@ -1,120 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/container/vector/vector_iterator.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/view/filter_view/filter_view.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/arg.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<Y-object>";
|
||||
}
|
||||
};
|
||||
|
||||
struct reject_all
|
||||
{
|
||||
template<typename T>
|
||||
struct apply : boost::mpl::false_
|
||||
{};
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
using boost::mpl::int_;
|
||||
using boost::mpl::_;
|
||||
using boost::mpl::not_;
|
||||
using boost::mpl::less;
|
||||
using boost::mpl::vector_c;
|
||||
using boost::is_class;
|
||||
using boost::is_same;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{ // Testing the static find_if (internal function)
|
||||
|
||||
typedef vector<int, char, long, X> vector_type;
|
||||
|
||||
vector_type v(1, 'x', 987654, X());
|
||||
typedef vector_iterator<vector_type, 0> begin;
|
||||
typedef vector_iterator<vector_type, 4> end;
|
||||
typedef detail::static_find_if<begin, end, is_same<_, long> > filter;
|
||||
typedef filter::type type;
|
||||
|
||||
BOOST_TEST(*type(v) == 987654);
|
||||
std::cout << *type(v) << std::endl;
|
||||
std::cout << *filter::call(begin(v)) << std::endl;
|
||||
BOOST_TEST(*type(v) == *filter::call(begin(v)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool, double> vector_type;
|
||||
|
||||
X x; Y y;
|
||||
vector_type v(y, '@', 987654, x, true, 6.6);
|
||||
typedef filter_view<vector_type const, not_<is_class<_> > > filter_view_type;
|
||||
filter_view_type view(v);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector('@', 987654, true, 6.6)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<filter_view_type>::value == 4);
|
||||
}
|
||||
|
||||
{
|
||||
// $$$ 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.
|
||||
|
||||
#ifndef __EDG_VERSION__
|
||||
typedef vector_c<int, 5, 1, 2, 3, 6, 0, -1> vector_type;
|
||||
typedef filter_view<vector_type const, less<_, int_<3> > > filter_view_type;
|
||||
vector_type v;
|
||||
filter_view_type view(v);
|
||||
std::cout << view << std::endl;
|
||||
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>
|
||||
// Picked up by Andreas Pokorny
|
||||
typedef vector<int> vec;
|
||||
typedef filter_view<vec, reject_all> filter_view_type;
|
||||
|
||||
BOOST_MPL_ASSERT((result_of::equal_to<result_of::begin<filter_view_type>::type, result_of::end<filter_view_type>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/deque/deque.hpp>
|
||||
#include <boost/fusion/container/deque/front_extended_deque.hpp>
|
||||
#include <boost/fusion/sequence/comparison.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
typedef deque<char, long> initial_deque_type;
|
||||
initial_deque_type initial_deque('a', 101L);
|
||||
typedef front_extended_deque<initial_deque_type, int> extended_type;
|
||||
extended_type extended(initial_deque, 1);
|
||||
|
||||
BOOST_TEST(size(extended) == 3);
|
||||
BOOST_TEST(extended == make_vector(1, 'a', 101L));
|
||||
BOOST_TEST(*begin(extended) == 1);
|
||||
BOOST_TEST(*next(begin(extended)) == 'a');
|
||||
BOOST_TEST(*prior(end(extended)) == 101L);
|
||||
BOOST_TEST(distance(begin(extended), end(extended)) == 3);
|
||||
BOOST_TEST(*advance_c<2>(begin(extended)) == 101L);
|
||||
}
|
||||
{
|
||||
namespace mpl = boost::mpl;
|
||||
typedef deque<char, long> initial_deque_type;
|
||||
typedef front_extended_deque<initial_deque_type, int> extended_type;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 0>::type, int>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 1>::type, char>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::at_c<extended_type, 2>::type, long>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<mpl::deref<mpl::begin<extended_type>::type>::type, int>));
|
||||
BOOST_MPL_ASSERT((mpl::equal_to<mpl::size<extended_type>::type, mpl::int_<3> >));
|
||||
}
|
||||
{
|
||||
char ch('a');
|
||||
long l(101L);
|
||||
int i(1);
|
||||
typedef deque<char&, long&> initial_deque_type;
|
||||
initial_deque_type initial_deque(ch, l);
|
||||
typedef front_extended_deque<initial_deque_type, int&> extended_type;
|
||||
extended_type extended(initial_deque, i);
|
||||
BOOST_TEST(extended == make_vector(1, 'a', 101L));
|
||||
|
||||
char ch2('b');
|
||||
long l2(202L);
|
||||
int i2(2);
|
||||
extended_type extended2(initial_deque_type(ch2, l2), i2);
|
||||
|
||||
extended = extended2;
|
||||
|
||||
BOOST_TEST(extended == make_vector(2, 'b', 202L));
|
||||
|
||||
BOOST_TEST(i == i2);
|
||||
BOOST_TEST(ch == ch2);
|
||||
BOOST_TEST(l == l2);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko J<>rvi
|
||||
|
||||
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/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/io/in.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#if defined BOOST_NO_STRINGSTREAM
|
||||
# include <strstream>
|
||||
#else
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
using boost::fusion::vector;
|
||||
using boost::fusion::make_vector;
|
||||
using boost::fusion::tuple_close;
|
||||
using boost::fusion::tuple_open;
|
||||
using boost::fusion::tuple_delimiter;
|
||||
|
||||
#if defined BOOST_NO_STRINGSTREAM
|
||||
using std::ostrstream;
|
||||
using std::istrstream;
|
||||
typedef ostrstream useThisOStringStream;
|
||||
typedef istrstream useThisIStringStream;
|
||||
#else
|
||||
using std::ostringstream;
|
||||
using std::istringstream;
|
||||
typedef ostringstream useThisOStringStream;
|
||||
typedef istringstream useThisIStringStream;
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
using std::ofstream;
|
||||
using std::ifstream;
|
||||
using std::string;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using boost::fusion::tuple_close;
|
||||
using boost::fusion::tuple_open;
|
||||
using boost::fusion::tuple_delimiter;
|
||||
|
||||
useThisOStringStream os1;
|
||||
|
||||
// Set format [a, b, c] for os1
|
||||
os1 << tuple_open('[');
|
||||
os1 << tuple_close(']');
|
||||
os1 << tuple_delimiter(',');
|
||||
os1 << make_vector(1, 2, 3);
|
||||
|
||||
BOOST_TEST (os1.str() == std::string("[1,2,3]") );
|
||||
|
||||
{
|
||||
useThisOStringStream os2;
|
||||
// Set format (a:b:c) for os2;
|
||||
os2 << tuple_open('(');
|
||||
os2 << tuple_close(')');
|
||||
os2 << tuple_delimiter(':');
|
||||
|
||||
os2 << make_vector("TUPU", "HUPU", "LUPU", 4.5);
|
||||
BOOST_TEST (os2.str() == std::string("(TUPU:HUPU:LUPU:4.5)") );
|
||||
}
|
||||
|
||||
// The format is still [a, b, c] for os1
|
||||
os1 << make_vector(1, 2, 3);
|
||||
BOOST_TEST (os1.str() == std::string("[1,2,3][1,2,3]") );
|
||||
|
||||
std::ofstream tmp("temp.tmp");
|
||||
|
||||
tmp << make_vector("One", "Two", 3);
|
||||
tmp << tuple_delimiter(':');
|
||||
tmp << make_vector(1000, 2000, 3000) << endl;
|
||||
|
||||
tmp.close();
|
||||
|
||||
// When reading tuples from a stream, manipulators must be set correctly:
|
||||
ifstream tmp3("temp.tmp");
|
||||
vector<string, string, int> j;
|
||||
|
||||
tmp3 >> j;
|
||||
BOOST_TEST (tmp3.good() );
|
||||
|
||||
tmp3 >> tuple_delimiter(':');
|
||||
vector<int, int, int> i;
|
||||
tmp3 >> i;
|
||||
BOOST_TEST (tmp3.good() );
|
||||
|
||||
tmp3.close();
|
||||
|
||||
// reading vector<int, int, int> in format (a b c);
|
||||
useThisIStringStream is("(100 200 300)");
|
||||
|
||||
vector<int, int, int> ti;
|
||||
BOOST_TEST(bool((is >> ti) != 0));
|
||||
BOOST_TEST(ti == make_vector(100, 200, 300));
|
||||
|
||||
// Note that strings are problematic:
|
||||
// writing a tuple on a stream and reading it back doesn't work in
|
||||
// general. If this is wanted, some kind of a parseable string class
|
||||
// should be used.
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,197 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <string>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
#include <boost/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
|
||||
|
||||
void test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
{ // Testing deref, next, prior, begin, end
|
||||
|
||||
char const* s = "Hello";
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
|
||||
seq_type v(1, 'x', 3.3, s);
|
||||
result_of::begin<seq_type>::type i(v);
|
||||
|
||||
BOOST_TEST(*i == 1);
|
||||
BOOST_TEST(*next(i) == 'x');
|
||||
BOOST_TEST(*next(next(i)) == 3.3);
|
||||
BOOST_TEST(*next(next(next(i))) == s);
|
||||
next(next(next(next(i)))); // end
|
||||
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*prior(next(next(next(i)))) == 3.3);
|
||||
BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x');
|
||||
BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1);
|
||||
#endif
|
||||
BOOST_TEST(*begin(v) == 1);
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*prior(end(v)) == s);
|
||||
#endif
|
||||
|
||||
*i = 3;
|
||||
BOOST_TEST(*i == 3);
|
||||
BOOST_TEST(&*i == &at_c<0>(v));
|
||||
|
||||
// prove that it is mutable
|
||||
*i = 987;
|
||||
BOOST_TEST(*i == 987);
|
||||
}
|
||||
|
||||
{ // Testing const sequence and const iterator
|
||||
|
||||
char const* s = "Hello";
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> const seq_type;
|
||||
seq_type t(1, 'x', 3.3, s);
|
||||
result_of::begin<seq_type>::type i(t);
|
||||
|
||||
BOOST_TEST(*i == 1);
|
||||
BOOST_TEST(*next(i) == 'x');
|
||||
BOOST_TEST(*begin(t) == 1);
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*prior(end(t)) == s);
|
||||
#endif
|
||||
|
||||
#ifdef FUSION_TEST_FAIL
|
||||
*i = 3; // must not compile
|
||||
#endif
|
||||
}
|
||||
|
||||
{ // Testing iterator equality
|
||||
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> const cseq_type;
|
||||
typedef result_of::begin<seq_type>::type vi1;
|
||||
typedef result_of::begin<cseq_type>::type vi2;
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi1>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi1 const>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi2>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi2>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1, vi2 const>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::equal_to<vi1 const, vi2 const>::value));
|
||||
}
|
||||
|
||||
{
|
||||
typedef FUSION_SEQUENCE<int, int> seq_type;
|
||||
typedef result_of::begin<seq_type>::type begin_type;
|
||||
typedef result_of::end<seq_type>::type end_type;
|
||||
typedef result_of::next<begin_type>::type i1;
|
||||
typedef result_of::next<i1>::type i2;
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<end_type, i2>::value));
|
||||
}
|
||||
|
||||
{ // testing deref, next, prior, begin, end
|
||||
|
||||
char const* s = "Hello";
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
|
||||
seq_type t(1, 'x', 3.3, s);
|
||||
result_of::begin<seq_type>::type i(t);
|
||||
|
||||
BOOST_TEST(*i == 1);
|
||||
BOOST_TEST(*next(i) == 'x');
|
||||
BOOST_TEST(*next(next(i)) == 3.3);
|
||||
BOOST_TEST(*next(next(next(i))) == s);
|
||||
|
||||
next(next(next(next(i)))); // end
|
||||
|
||||
#ifdef FUSION_TEST_FAIL
|
||||
next(next(next(next(next(i))))); // past the end: must not compile
|
||||
#endif
|
||||
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*prior(next(next(next(i)))) == 3.3);
|
||||
BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x');
|
||||
BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1);
|
||||
#endif
|
||||
BOOST_TEST(*begin(t) == 1);
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*prior(end(t)) == s);
|
||||
#endif
|
||||
|
||||
*i = 3;
|
||||
BOOST_TEST(*i == 3);
|
||||
BOOST_TEST(*i == at_c<0>(t));
|
||||
}
|
||||
|
||||
{ // Testing distance
|
||||
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
|
||||
seq_type t(1, 'x', 3.3, "Hello");
|
||||
|
||||
BOOST_STATIC_ASSERT((result_of::distance<
|
||||
result_of::begin<seq_type>::type
|
||||
, result_of::end<seq_type>::type >::value == 4));
|
||||
|
||||
BOOST_TEST(distance(begin(t), end(t)).value == 4);
|
||||
}
|
||||
|
||||
{ // Testing tuple iterator result_of::value_of, result_of::deref, result_of::value_at
|
||||
|
||||
typedef FUSION_SEQUENCE<int, char&> seq_type;
|
||||
typedef result_of::begin<seq_type>::type i0;
|
||||
typedef result_of::next<i0>::type i1;
|
||||
typedef result_of::next<result_of::begin<const seq_type>::type>::type i2;
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<result_of::value_at_c<seq_type, 0>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<result_of::value_at_c<seq_type, 1>::type, char&>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<traits::category_of<i0>::type, FUSION_TRAVERSAL_TAG>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::deref<i0>::type, int&>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::deref<i1>::type, char&>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of<i0>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<result_of::value_of<i1>::type, char&>::value));
|
||||
}
|
||||
|
||||
{ // Testing advance
|
||||
|
||||
typedef FUSION_SEQUENCE<int, char, double, char const*> seq_type;
|
||||
seq_type t(1, 'x', 3.3, "Hello");
|
||||
|
||||
BOOST_TEST(*advance_c<0>(begin(t)) == at_c<0>(t));
|
||||
BOOST_TEST(*advance_c<1>(begin(t)) == at_c<1>(t));
|
||||
BOOST_TEST(*advance_c<2>(begin(t)) == at_c<2>(t));
|
||||
BOOST_TEST(*advance_c<3>(begin(t)) == at_c<3>(t));
|
||||
|
||||
#if !defined(FUSION_NO_PRIOR)
|
||||
BOOST_TEST(*advance_c<-1>(end(t)) == at_c<3>(t));
|
||||
BOOST_TEST(*advance_c<-2>(end(t)) == at_c<2>(t));
|
||||
BOOST_TEST(*advance_c<-3>(end(t)) == at_c<1>(t));
|
||||
BOOST_TEST(*advance_c<-4>(end(t)) == at_c<0>(t));
|
||||
#endif
|
||||
|
||||
BOOST_TEST(&*advance_c<0>(begin(t)) == &at_c<0>(t));
|
||||
BOOST_TEST(&*advance_c<1>(begin(t)) == &at_c<1>(t));
|
||||
BOOST_TEST(&*advance_c<2>(begin(t)) == &at_c<2>(t));
|
||||
BOOST_TEST(&*advance_c<3>(begin(t)) == &at_c<3>(t));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef vector<int, char, double, char const*> vector_type;
|
||||
vector_type vec(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
typedef vector_iterator<vector_type, 1> i1t;
|
||||
typedef vector_iterator<vector_type, 3> i3t;
|
||||
|
||||
i1t i1(vec);
|
||||
i3t i3(vec);
|
||||
|
||||
typedef iterator_range<i1t, i3t> slice_t;
|
||||
slice_t slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST((slice == make_vector('x', 3.3)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector_iterator<vector_type, 0> i1t;
|
||||
typedef vector_iterator<vector_type, 0> i3t;
|
||||
|
||||
i1t i1(vec);
|
||||
i3t i3(vec);
|
||||
|
||||
typedef iterator_range<i1t, i3t> slice_t;
|
||||
slice_t slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST(slice == make_vector());
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
|
||||
typedef boost::mpl::begin<mpl_vec>::type it0;
|
||||
typedef boost::mpl::next<it0>::type it1;
|
||||
typedef boost::mpl::next<it1>::type it2;
|
||||
typedef boost::mpl::next<it2>::type it3;
|
||||
|
||||
it1 f;
|
||||
it3 l;
|
||||
|
||||
typedef iterator_range<it1, it3> slice_t;
|
||||
slice_t slice(f, l);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST((slice == make_vector(3, 4)));
|
||||
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,144 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/view/joint_view/joint_view.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/sequence/intrinsic/at.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing joint_view
|
||||
|
||||
{
|
||||
vector<int> t1(3);
|
||||
vector<X> t2;
|
||||
typedef joint_view<vector<int>, vector<X> > view_type;
|
||||
view_type view(t1, t2);
|
||||
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector(3, X())));
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, char> t1(3, 'x');
|
||||
vector<X> t2;
|
||||
typedef joint_view<vector<int, char>, vector<X> > view_type;
|
||||
view_type view(t1, t2);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector(3, 'x', X())));
|
||||
|
||||
*begin(view) = 4;
|
||||
BOOST_TEST(at_c<0>(t1) == 4);
|
||||
}
|
||||
|
||||
{
|
||||
vector<int, char> t1(3, 'x');
|
||||
vector<X, int> t2;
|
||||
typedef joint_view<vector<int, char>, vector<X, int> > view_type;
|
||||
view_type view(t1, t2);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector(3, 'x', X(), 0)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int> t1_type;
|
||||
t1_type t1(777);
|
||||
typedef vector<int, char, double> t2_type;
|
||||
t2_type t2(1, 'x', 3.3);
|
||||
|
||||
{
|
||||
typedef joint_view<t1_type, t2_type> view_type;
|
||||
view_type view(t1, t2);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector(777, 1, 'x', 3.3)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t2_type, t1_type> view_type;
|
||||
view_type view(t2, t1);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_vector(1, 'x', 3.3, 777)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t2_type, t1_type> jv_type;
|
||||
typedef joint_view<jv_type, jv_type> jv2_type;
|
||||
|
||||
jv_type jv(t2, t1);
|
||||
jv2_type jv2(jv, jv);
|
||||
|
||||
std::cout << jv << std::endl;
|
||||
std::cout << jv2 << std::endl;
|
||||
|
||||
BOOST_TEST(jv2
|
||||
== make_vector(1, 'x', 3.3, 777, 1, 'x', 3.3, 777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t2_type, t1_type> jt_type;
|
||||
typedef joint_view<t1_type, t2_type> jv2_type;
|
||||
typedef joint_view<jt_type, jv2_type> jv3_type;
|
||||
|
||||
jt_type jt(t2, t1);
|
||||
jv2_type jv2(t1, t2);
|
||||
jv3_type jv3(jt, jv2);
|
||||
|
||||
std::cout << jt << std::endl;
|
||||
std::cout << jv2 << std::endl;
|
||||
std::cout << jv3 << std::endl;
|
||||
|
||||
BOOST_TEST(jv3
|
||||
== make_vector(1, 'x', 3.3, 777, 777, 1, 'x', 3.3));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<vector<>, t1_type> jt_type;
|
||||
vector<> empty;
|
||||
jt_type jt(empty, t1);
|
||||
std::cout << jt << std::endl;
|
||||
BOOST_TEST(jt == make_vector(777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t1_type, vector<> > jt_type;
|
||||
vector<> empty;
|
||||
jt_type jt(t1, empty);
|
||||
std::cout << jt << std::endl;
|
||||
BOOST_TEST(jt == make_vector(777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<vector<>, vector<> > jt_type;
|
||||
vector<> empty;
|
||||
jt_type jt(empty, empty);
|
||||
std::cout << jt << std::endl;
|
||||
BOOST_TEST(jt == make_vector());
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "comparison.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
equality_test();
|
||||
ordering_test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "construction.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
#include <boost/fusion/container/generation/list_tie.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "copy.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#define FUSION_NO_PRIOR
|
||||
#define FUSION_TRAVERSAL_TAG forward_traversal_tag
|
||||
#include "./iterator.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "make.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/list/convert.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#define FUSION_FORWARD_ONLY
|
||||
#include "misc.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "mutate.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/list_tie.hpp>
|
||||
#include <boost/fusion/container/generation/ignore.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "tie.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "value_at.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <string>
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
|
||||
#if !defined(FUSION_MAKE)
|
||||
#define FUSION_MAKE BOOST_PP_CAT(make_, FUSION_SEQUENCE)
|
||||
#endif
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
// something to prevent warnings for unused variables
|
||||
template<class T> void dummy(const T&) {}
|
||||
|
||||
class A {};
|
||||
class B {};
|
||||
}
|
||||
|
||||
void make_tuple_test() {}
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace test_detail;
|
||||
|
||||
{
|
||||
FUSION_SEQUENCE<int, char> t1 = FUSION_MAKE(5, 'a');
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == 5);
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == 'a');
|
||||
|
||||
FUSION_SEQUENCE<int, std::string> t2;
|
||||
t2 = FUSION_MAKE((short int)2, std::string("Hi"));
|
||||
BOOST_TEST(FUSION_AT<0>(t2) == 2);
|
||||
BOOST_TEST(FUSION_AT<1>(t2) == "Hi");
|
||||
}
|
||||
|
||||
{ // This test was previously disallowed for non-PTS compilers.
|
||||
A a = A(); B b;
|
||||
const A ca = a;
|
||||
FUSION_MAKE(boost::cref(a), b);
|
||||
FUSION_MAKE(boost::ref(a), b);
|
||||
FUSION_MAKE(boost::ref(a), boost::cref(b));
|
||||
FUSION_MAKE(boost::ref(ca));
|
||||
}
|
||||
|
||||
{ // the result of make_xxx is assignable:
|
||||
BOOST_TEST(FUSION_MAKE(2, 4, 6) ==
|
||||
(FUSION_MAKE(1, 2, 3) = FUSION_MAKE(2, 4, 6)));
|
||||
}
|
||||
|
||||
{ // This test was previously disallowed for non-PTS compilers.
|
||||
FUSION_MAKE("Donald", "Daisy"); // should work;
|
||||
// std::make_pair("Doesn't","Work"); // fails
|
||||
}
|
||||
|
||||
{
|
||||
// You can store a reference to a function in a sequence
|
||||
FUSION_SEQUENCE<void(&)()> adf(make_tuple_test);
|
||||
dummy(adf); // avoid warning for unused variable
|
||||
}
|
||||
|
||||
#if defined(FUSION_TEST_FAIL)
|
||||
{
|
||||
// But make_xxx doesn't work
|
||||
// with function references, since it creates a const
|
||||
// qualified function type
|
||||
|
||||
FUSION_MAKE(make_tuple_test);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
// With function pointers, make_xxx works just fine
|
||||
FUSION_MAKE(&make_tuple_test);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_list.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE list
|
||||
#include "make.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
|
||||
#define FUSION_SEQUENCE vector
|
||||
#include "make.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/map/map.hpp>
|
||||
#include <boost/fusion/container/generation/make_map.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using boost::fusion::pair;
|
||||
using boost::fusion::make_pair;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
typedef map<
|
||||
pair<int, char>
|
||||
, pair<double, std::string> >
|
||||
map_type;
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_associative<map_type>));
|
||||
|
||||
map_type m(
|
||||
make_pair<int>('X')
|
||||
, make_pair<double>("Men"));
|
||||
|
||||
std::cout << at_key<int>(m) << std::endl;
|
||||
std::cout << at_key<double>(m) << std::endl;
|
||||
|
||||
BOOST_TEST(at_key<int>(m) == 'X');
|
||||
BOOST_TEST(at_key<double>(m) == "Men");
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<result_of::value_at_key<map_type, int>::type, char>::value));
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<result_of::value_at_key<map_type, double>::type, std::string>::value));
|
||||
|
||||
std::cout << m << std::endl;
|
||||
|
||||
BOOST_STATIC_ASSERT((result_of::has_key<map_type, int>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::has_key<map_type, double>::value));
|
||||
BOOST_STATIC_ASSERT((!result_of::has_key<map_type, std::string>::value));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << make_map<char, int>('X', 123) << std::endl;
|
||||
BOOST_TEST(at_key<char>(make_map<char, int>('X', 123)) == 'X');
|
||||
BOOST_TEST(at_key<int>(make_map<char, int>('X', 123)) == 123);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 2006 Dan Marsden
|
||||
|
||||
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/generation/map_tie.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
|
||||
struct key_zero;
|
||||
struct key_one;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
{
|
||||
int number = 101;
|
||||
char letter = 'a';
|
||||
BOOST_TEST(at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) == 101);
|
||||
BOOST_TEST(at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) == 'a');
|
||||
|
||||
BOOST_TEST(&at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) == &number);
|
||||
BOOST_TEST(&at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) == &letter);
|
||||
|
||||
at_key<key_zero>(map_tie<key_zero, key_one>(number, letter)) = 202;
|
||||
at_key<key_one>(map_tie<key_zero, key_one>(number, letter)) = 'b';
|
||||
|
||||
BOOST_TEST(number == 202);
|
||||
BOOST_TEST(letter == 'b');
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/mpl.hpp>
|
||||
#include <boost/mpl/find.hpp>
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <string>
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
|
||||
#if !defined(FUSION_SIZE)
|
||||
#define FUSION_SIZE result_of::size
|
||||
#endif
|
||||
|
||||
template <typename S1, typename S2>
|
||||
struct is_same
|
||||
{
|
||||
};
|
||||
|
||||
struct test_intrinsics1
|
||||
{
|
||||
// test at, begin, end, next, prior, advance, size, deref, etc.
|
||||
|
||||
typedef boost::fusion::FUSION_SEQUENCE<int, float, bool, char> sequence;
|
||||
typedef boost::mpl::begin<sequence>::type first;
|
||||
typedef boost::mpl::next<first>::type second;
|
||||
typedef boost::mpl::next<second>::type third;
|
||||
typedef boost::mpl::next<third>::type fourth;
|
||||
typedef boost::mpl::end<sequence>::type last;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<first>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<second>::type, float>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<third>::type, bool>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<fourth>::type, char>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::at_c<sequence, 2>::type, bool>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::front<sequence>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<
|
||||
boost::mpl::advance_c<second, 2>::type>::type, char>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::mpl::size<sequence>::value == 4));
|
||||
BOOST_STATIC_ASSERT(!(boost::mpl::empty<sequence>::value));
|
||||
BOOST_STATIC_ASSERT((boost::mpl::distance<second, fourth>::value == 2));
|
||||
|
||||
#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev
|
||||
|
||||
typedef boost::mpl::prior<last>::type fourth_;
|
||||
typedef boost::mpl::prior<fourth_>::type third_;
|
||||
typedef boost::mpl::prior<third_>::type second_;
|
||||
typedef boost::mpl::prior<second_>::type first_;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<first_>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<second_>::type, float>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<third_>::type, bool>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::deref<fourth_>::type, char>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
boost::mpl::back<sequence>::type, char>::value));
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
struct test_intrinsics2
|
||||
{
|
||||
typedef boost::fusion::FUSION_SEQUENCE<> seq0;
|
||||
|
||||
#if !defined(FUSION_FORWARD_ONLY) // list has no back/prev
|
||||
|
||||
typedef boost::fusion::FUSION_SEQUENCE<int> target1;
|
||||
typedef boost::mpl::push_back<seq0, int>::type seq1;
|
||||
BOOST_STATIC_ASSERT((boost::mpl::equal<seq1, target1>::value));
|
||||
|
||||
typedef boost::fusion::FUSION_SEQUENCE<int, double> target2;
|
||||
typedef boost::mpl::push_back<seq1, double>::type seq2;
|
||||
BOOST_STATIC_ASSERT((boost::mpl::equal<seq2, target2>::value));
|
||||
|
||||
#endif
|
||||
|
||||
typedef boost::fusion::FUSION_SEQUENCE<int> target3;
|
||||
typedef boost::mpl::push_front<seq0, int>::type seq3;
|
||||
BOOST_STATIC_ASSERT((boost::mpl::equal<seq3, target3>::value));
|
||||
|
||||
typedef boost::fusion::FUSION_SEQUENCE<double, int> target4;
|
||||
typedef boost::mpl::push_front<seq3, double>::type seq4;
|
||||
BOOST_STATIC_ASSERT((boost::mpl::equal<seq4, target4>::value));
|
||||
};
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{ // testing const sequences
|
||||
|
||||
const FUSION_SEQUENCE<int, float> t1(5, 3.3f);
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == 5);
|
||||
BOOST_TEST(FUSION_AT<1>(t1) == 3.3f);
|
||||
}
|
||||
|
||||
{ // testing at<N> works with MPL integral constants
|
||||
const FUSION_SEQUENCE<int, char> t1(101, 'z');
|
||||
BOOST_TEST(boost::fusion::at<boost::mpl::int_<0> >(t1) == 101);
|
||||
BOOST_TEST(boost::fusion::at<boost::mpl::int_<1> >(t1) == 'z');
|
||||
// explicitly try something other than mpl::int_
|
||||
BOOST_TEST((boost::fusion::at<boost::mpl::integral_c<long, 0> >(t1) == 101));
|
||||
BOOST_TEST((boost::fusion::at<boost::mpl::integral_c<long, 1> >(t1) == 'z'));
|
||||
}
|
||||
|
||||
{ // testing size & empty
|
||||
|
||||
typedef FUSION_SEQUENCE<int, float, double> t1;
|
||||
typedef FUSION_SEQUENCE<> t2;
|
||||
|
||||
BOOST_STATIC_ASSERT(FUSION_SIZE<t1>::value == 3);
|
||||
BOOST_STATIC_ASSERT(FUSION_SIZE<t2>::value == 0);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<t1>::value);
|
||||
BOOST_STATIC_ASSERT(result_of::empty<t2>::value);
|
||||
}
|
||||
|
||||
{ // testing front & back
|
||||
|
||||
typedef FUSION_SEQUENCE<int, float, std::string> tup;
|
||||
tup t(1, 2.2, "Kimpo");
|
||||
|
||||
BOOST_TEST(front(t) == 1);
|
||||
#if !defined(FUSION_FORWARD_ONLY) // list has no back
|
||||
BOOST_TEST(back(t) == "Kimpo");
|
||||
#endif
|
||||
}
|
||||
|
||||
{ // testing is_sequence
|
||||
|
||||
typedef FUSION_SEQUENCE<int, float, double> t1;
|
||||
typedef FUSION_SEQUENCE<> t2;
|
||||
typedef FUSION_SEQUENCE<char> t3;
|
||||
|
||||
BOOST_STATIC_ASSERT(traits::is_sequence<t1>::value);
|
||||
BOOST_STATIC_ASSERT(traits::is_sequence<t2>::value);
|
||||
BOOST_STATIC_ASSERT(traits::is_sequence<t3>::value);
|
||||
BOOST_STATIC_ASSERT(!traits::is_sequence<int>::value);
|
||||
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
|
||||
}
|
||||
|
||||
{ // testing mpl compatibility
|
||||
|
||||
// test begin, end, next, prior, advance, size, deref, etc.
|
||||
//~ typedef FUSION_SEQUENCE<int, float, bool, char> tuple_type;
|
||||
//~ test_intrinsics1<tuple_type> test1;
|
||||
//~ (void)test1; // prevent unused variable warning
|
||||
|
||||
// test an algorithm
|
||||
typedef FUSION_SEQUENCE<int, float, double> t1;
|
||||
typedef boost::mpl::find<t1, float>::type iter;
|
||||
typedef boost::mpl::deref<iter>::type type;
|
||||
BOOST_STATIC_ASSERT((boost::is_same<type, float>::value));
|
||||
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 1999-2003 Jaakko J<>rvi
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
|
||||
#if !defined(FUSION_AT)
|
||||
#define FUSION_AT at_c
|
||||
#endif
|
||||
|
||||
namespace test_detail
|
||||
{
|
||||
// no public default constructor
|
||||
class foo
|
||||
{
|
||||
public:
|
||||
|
||||
explicit foo(int v) : val(v) {}
|
||||
|
||||
bool operator==(const foo& other) const
|
||||
{
|
||||
return val == other.val;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
foo() {}
|
||||
int val;
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace test_detail;
|
||||
|
||||
FUSION_SEQUENCE<int, float, bool, foo> t1(5, 12.2f, true, foo(4));
|
||||
FUSION_AT<0>(t1) = 6;
|
||||
FUSION_AT<1>(t1) = 2.2f;
|
||||
FUSION_AT<2>(t1) = false;
|
||||
FUSION_AT<3>(t1) = foo(5);
|
||||
|
||||
BOOST_TEST(FUSION_AT<0>(t1) == 6);
|
||||
BOOST_TEST(FUSION_AT<1>(t1) > 2.1f && FUSION_AT<1>(t1) < 2.3f);
|
||||
BOOST_TEST(FUSION_AT<2>(t1) == false);
|
||||
BOOST_TEST(FUSION_AT<3>(t1) == foo(5));
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 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/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/view/repetitive_view.hpp>
|
||||
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/view/joint_view.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/zip.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
|
||||
#include <boost/fusion/functional/generation/make_fused_procedure.hpp>
|
||||
|
||||
struct check_equal
|
||||
{
|
||||
template<typename LHS, typename RHS>
|
||||
void operator()(LHS const& lhs, RHS const& rhs) const
|
||||
{
|
||||
BOOST_TEST(( boost::is_same<LHS,RHS>::value ));
|
||||
BOOST_TEST(( lhs == rhs ));
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
typedef boost::fusion::vector<int,long,float,double> seq_t;
|
||||
seq_t seq(1,2l,3.0f,4.0);
|
||||
|
||||
typedef repetitive_view<seq_t> view_t;
|
||||
view_t view(seq);
|
||||
|
||||
typedef joint_view<seq_t,seq_t> seq_twice_t;
|
||||
typedef joint_view<seq_t,seq_twice_t> seq_repeated_t;
|
||||
seq_twice_t seq_twice(seq,seq);
|
||||
seq_repeated_t seq_repeated(seq,seq_twice);
|
||||
|
||||
for_each(zip(view,seq_repeated), make_fused_procedure(check_equal()));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/view/reverse_view/reverse_view.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/iterator/prior.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing the reverse_view
|
||||
|
||||
{
|
||||
typedef boost::mpl::range_c<int, 5, 9> mpl_list1;
|
||||
mpl_list1 l;
|
||||
reverse_view<mpl_list1> rev(l);
|
||||
|
||||
std::cout << rev << std::endl;
|
||||
BOOST_TEST((rev == make_vector(8, 7, 6, 5)));
|
||||
}
|
||||
|
||||
{
|
||||
char const* s = "Hi Kim";
|
||||
typedef vector<int, char, long, char const*> vector_type;
|
||||
vector_type t(123, 'x', 123456789, s);
|
||||
typedef reverse_view<vector_type> view_type;
|
||||
view_type rev(t);
|
||||
|
||||
std::cout << rev << std::endl;
|
||||
BOOST_TEST((rev == make_vector(s, 123456789, 'x', 123)));
|
||||
|
||||
typedef result_of::begin<view_type>::type first_type;
|
||||
first_type first_it(begin(rev));
|
||||
typedef result_of::next<first_type>::type second_type;
|
||||
second_type second_it(next(first_it));
|
||||
BOOST_TEST((*second_it == 123456789));
|
||||
BOOST_TEST((*prior(second_it) == s));
|
||||
BOOST_TEST((*advance_c<2>(first_it) == 'x'));
|
||||
BOOST_TEST((distance(first_it, second_it) == 1));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/set/set.hpp>
|
||||
#include <boost/fusion/container/generation/make_set.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using boost::fusion::pair;
|
||||
using boost::fusion::make_pair;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
typedef set<int, std::string> set_type;
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_associative<set_type>));
|
||||
|
||||
set_type m(123, "Hola");
|
||||
|
||||
std::cout << at_key<int>(m) << std::endl;
|
||||
std::cout << at_key<std::string>(m) << std::endl;
|
||||
|
||||
BOOST_TEST(at_key<int>(m) == 123);
|
||||
BOOST_TEST(at_key<std::string>(m) == "Hola");
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<result_of::value_at_key<set_type, int>::type, int>::value));
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<result_of::value_at_key<set_type, std::string>::type, std::string>::value));
|
||||
|
||||
std::cout << m << std::endl;
|
||||
|
||||
BOOST_STATIC_ASSERT((result_of::has_key<set_type, int>::value));
|
||||
BOOST_STATIC_ASSERT((result_of::has_key<set_type, std::string>::value));
|
||||
BOOST_STATIC_ASSERT((!result_of::has_key<set_type, double>::value));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << make_set('X', 123) << std::endl;
|
||||
BOOST_TEST(at_key<char>(make_set('X', 123)) == 'X');
|
||||
BOOST_TEST(at_key<int>(make_set('X', 123)) == 123);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/view/single_view/single_view.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
struct X {};
|
||||
|
||||
template <typename OS>
|
||||
OS& operator<<(OS& os, X const&)
|
||||
{
|
||||
os << "<X-object>";
|
||||
return os;
|
||||
}
|
||||
|
||||
void foo() {}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
single_view<int> view1(3);
|
||||
std::cout << view1 << std::endl;
|
||||
|
||||
#ifdef FUSION_TEST_FAIL
|
||||
// single_view is immutable
|
||||
*begin(view1) += 4;
|
||||
#endif
|
||||
std::cout << view1 << std::endl;
|
||||
BOOST_TEST(*begin(view1) == 3);
|
||||
BOOST_TEST(view1.val == 3);
|
||||
|
||||
single_view<X> view2;
|
||||
std::cout << view2 << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << make_single_view(1) << std::endl;
|
||||
std::cout << make_single_view("Hello, World") << std::endl;
|
||||
std::cout << make_single_view(&foo) << std::endl;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,91 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/back.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/list/list.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/not_equal_to.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less.hpp>
|
||||
#include <boost/fusion/sequence/comparison/less_equal.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater.hpp>
|
||||
#include <boost/fusion/sequence/comparison/greater_equal.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
{
|
||||
typedef std::pair<int, std::string> pair_type;
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<pair_type>));
|
||||
pair_type p(123, "Hola!!!");
|
||||
|
||||
std::cout << at_c<0>(p) << std::endl;
|
||||
std::cout << at_c<1>(p) << std::endl;
|
||||
std::cout << p << std::endl;
|
||||
BOOST_TEST(p == make_vector(123, "Hola!!!"));
|
||||
|
||||
at_c<0>(p) = 6;
|
||||
at_c<1>(p) = "mama mia";
|
||||
BOOST_TEST(p == make_vector(6, "mama mia"));
|
||||
|
||||
BOOST_STATIC_ASSERT(result_of::size<pair_type>::value == 2);
|
||||
BOOST_STATIC_ASSERT(!result_of::empty<pair_type>::value);
|
||||
|
||||
BOOST_TEST(front(p) == 6);
|
||||
BOOST_TEST(back(p) == "mama mia");
|
||||
}
|
||||
|
||||
{
|
||||
fusion::vector<int, float> v1(4, 3.3f);
|
||||
std::pair<short, float> v2(5, 3.3f);
|
||||
fusion::vector<long, double> v3(5, 4.4);
|
||||
BOOST_TEST(v1 < v2);
|
||||
BOOST_TEST(v1 <= v2);
|
||||
BOOST_TEST(v2 > v1);
|
||||
BOOST_TEST(v2 >= v1);
|
||||
BOOST_TEST(v2 < v3);
|
||||
BOOST_TEST(v2 <= v3);
|
||||
BOOST_TEST(v3 > v2);
|
||||
BOOST_TEST(v3 >= v2);
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from pair to vector
|
||||
fusion::vector<int, std::string> v(std::make_pair(123, "Hola!!!"));
|
||||
v = std::make_pair(123, "Hola!!!");
|
||||
}
|
||||
|
||||
{
|
||||
// conversion from pair to list
|
||||
fusion::list<int, std::string> l(std::make_pair(123, "Hola!!!"));
|
||||
l = std::make_pair(123, "Hola!!!");
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user