mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
Removing Fusion1
[SVN r34927]
This commit is contained in:
@@ -1,133 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
Fusion Tuples Library
|
||||
|
||||
This is a re-implementation of the TR tuples with iterators, views and
|
||||
algorithms. The structure is somewhat modeled after MPL. It is code-named
|
||||
"fusion" because the library is the "fusion" of compile time
|
||||
metaprogramming with runtime programming.
|
||||
|
||||
Overall structure:
|
||||
|
||||
The library is composed of three sub-modules. Iterators, Sequences and
|
||||
Views and Algorithms.
|
||||
|
||||
Iterators:
|
||||
|
||||
Generic iteration for heterogeneous types. The library is based on
|
||||
iterators.
|
||||
|
||||
filter_view_iterator
|
||||
filtering iterator. Given an MPL predicate, skips elements to
|
||||
present only the items that passes the predicate. See filter_view
|
||||
below.
|
||||
|
||||
joint_view_iterator
|
||||
Holds four iterators (two begin/end pairs). Iterates over the
|
||||
first pair then switches over to the next pair to present
|
||||
a contiguous whole. See joint_view below.
|
||||
|
||||
single_view_iterator
|
||||
A single element iterator. See single_view below.
|
||||
|
||||
cons_iterator
|
||||
An iterator into a cons list. See cons below.
|
||||
|
||||
transform_view_iterator
|
||||
Given a transform-function, transforms the elements being
|
||||
iterated. See transform_view below.
|
||||
|
||||
Sequences and Views:
|
||||
|
||||
Holds a begin/end iterator. Sequences and views may be composed to form
|
||||
more complex sequences and views. View/sequence composition is a very
|
||||
nice concept. These are extremely lighweight classes and can be passed
|
||||
around by value quite inexpensively. For instance, rather than working
|
||||
directly on tuples, the algorithms work on sequences and return
|
||||
sequences.
|
||||
|
||||
tuple
|
||||
The basic tuple structure
|
||||
|
||||
tupleN
|
||||
Fixed sized tuples (where N = 0 to a predefined limit)
|
||||
|
||||
filter_view
|
||||
Given an MPL predicate, filters the view to present only the items
|
||||
that passes the predicate.
|
||||
|
||||
single_view
|
||||
A single element view
|
||||
|
||||
joint_view
|
||||
A two-sequence view (concatenates two sequences)
|
||||
|
||||
cons
|
||||
A cons-cell that can be used to build a singly-linked list.
|
||||
|
||||
range
|
||||
Holds an iterator pair that represents a begin/end range.
|
||||
|
||||
transform_view
|
||||
Transforms a sequence given a transform-function
|
||||
|
||||
MPL sequences are also, automatically, fusion sequences. All algorithms
|
||||
and fusion functions that work on fusion sequences can also take in
|
||||
MPL seqneces.
|
||||
|
||||
Basic functions and meta_functions on sequences:
|
||||
|
||||
I/O : TR1-tuples compatible I/O routines
|
||||
operator : tuple operators ==, !=, <, >, <=, >=
|
||||
begin : start of sequence
|
||||
end : end of sequence
|
||||
make_tuple : make a tuple
|
||||
tie : make a tuple of references
|
||||
generate : given a fusion sequence, generate a tuple
|
||||
get<N> : get the nth element of a tuple
|
||||
is_sequence : checks if a type is a fusion sequence
|
||||
tuple_element : get the nth type in a tuple
|
||||
tuple_size : get the number of elements in a tuple
|
||||
|
||||
Algorithms:
|
||||
|
||||
With very complex composition of algorithms, it is not desirable to
|
||||
work directly on tuples. Like MPL, and unlike STL, the algorithms take
|
||||
in sequences/views and *return* the result by value; the algorithms are
|
||||
purely functional and do not (cannot) have side effects. We cannot have
|
||||
an out parameter that is passed by reference where the result is
|
||||
placed. The algorithms, instead, work on sequences and views and
|
||||
generate views.
|
||||
|
||||
This strategy is very efficient. You can think of the algorithms as
|
||||
"lazy". The values are generated only wnen it is needed -for example
|
||||
when generating a tuple. When you are sure that you need a tuple, you
|
||||
can "generate" it from the sequence: generate(sequence);
|
||||
|
||||
erase
|
||||
filter
|
||||
find
|
||||
find_if
|
||||
fold
|
||||
for_each
|
||||
insert
|
||||
push_back
|
||||
push_front
|
||||
remove
|
||||
remove_if
|
||||
replace
|
||||
transform
|
||||
any
|
||||
|
||||
TODO:
|
||||
iteration is limited to input_iterator
|
||||
fusion sequences to mpl mapping is not complete
|
||||
some relational operators are missing <, <=, >, >=
|
||||
some algorithms are missing (reverse, count, count_if, contains, append, etc.)
|
||||
some views are missing (reverse_view, set, map)
|
||||
get<N> should also work for all random access sequences, not only tuples
|
||||
@@ -1,218 +0,0 @@
|
||||
#==============================================================================
|
||||
# Copyright (c) 2003 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)
|
||||
#==============================================================================
|
||||
|
||||
subproject libs/spirit/fusion/test ;
|
||||
|
||||
unit-test fixed_tuple_tests
|
||||
: fixed_tuple_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_construction_tests
|
||||
: tuple_construction_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_element_access_tests
|
||||
: tuple_element_access_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_copy_tests
|
||||
: tuple_copy_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_comparison_tests
|
||||
: tuple_comparison_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test vc6_bug_001
|
||||
: vc6_bug_001.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_mutate_tests
|
||||
: tuple_mutate_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test misc_tuple_tests
|
||||
: misc_tuple_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test make_tuple_tests
|
||||
: make_tuple_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tie_tests
|
||||
: tie_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test tuple_iterator_tests
|
||||
: tuple_iterator_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test io_tests
|
||||
: io_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test single_view_tests
|
||||
: single_view_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test type_sequence_tests
|
||||
: type_sequence_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test joint_view_tests
|
||||
: joint_view_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test push_back_tests
|
||||
: push_back_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test push_front_tests
|
||||
: push_front_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test find_tests
|
||||
: find_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test find_if_tests
|
||||
: find_if_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test filter_view_tests
|
||||
: filter_view_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test filter_tests
|
||||
: filter_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test range_tests
|
||||
: range_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test erase_tests
|
||||
: erase_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test for_each_tests
|
||||
: for_each_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test fold_tests
|
||||
: fold_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test insert_tests
|
||||
: insert_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test remove_tests
|
||||
: remove_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test remove_if_tests
|
||||
: remove_if_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test replace_tests
|
||||
: replace_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test transform_view_tests
|
||||
: transform_view_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test transform_tests
|
||||
: transform_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test cons_tests
|
||||
: cons_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test any_tests
|
||||
: any_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
unit-test pair_tests
|
||||
: pair_tests.cpp
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
:
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/any.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/for_each.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
/// Testing any
|
||||
|
||||
{
|
||||
boost::fusion::tuple<int,short,double> t(1, 2, 3.3);
|
||||
BOOST_TEST((boost::fusion::any(t, boost::lambda::_1 == 2)));
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::tuple<int,short,double> t(1, 2, 3.3);
|
||||
BOOST_TEST((!boost::fusion::any(t, boost::lambda::_1 == 3)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <string>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/cons.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/for_each.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/filter.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/lambda.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::cout << boost::fusion::tuple_open('[');
|
||||
std::cout << boost::fusion::tuple_close(']');
|
||||
std::cout << boost::fusion::tuple_delimiter(", ");
|
||||
|
||||
/// Testing cons
|
||||
|
||||
{
|
||||
std::string hello("hello");
|
||||
boost::fusion::cons<int,boost::fusion::cons<std::string> > ns =
|
||||
boost::fusion::make_cons(1, boost::fusion::make_cons(hello));
|
||||
|
||||
BOOST_TEST((*boost::fusion::begin(ns) == 1));
|
||||
BOOST_TEST((*boost::fusion::next(boost::fusion::begin(ns)) == hello));
|
||||
|
||||
*boost::fusion::begin(ns) += 1;
|
||||
*boost::fusion::next(boost::fusion::begin(ns)) += ' ';
|
||||
|
||||
BOOST_TEST((*boost::fusion::begin(ns) == 2));
|
||||
BOOST_TEST((*boost::fusion::next(boost::fusion::begin(ns)) == hello + ' '));
|
||||
|
||||
boost::fusion::for_each(ns, boost::lambda::_1 += ' ');
|
||||
|
||||
BOOST_TEST((*boost::fusion::begin(ns) == 2 + ' '));
|
||||
BOOST_TEST((*boost::fusion::next(boost::fusion::begin(ns)) == hello + ' ' + ' '));
|
||||
}
|
||||
|
||||
{
|
||||
boost::fusion::tuple<int, float> t(1, 1.1f);
|
||||
boost::fusion::cons<int, boost::fusion::cons<float> > nf =
|
||||
boost::fusion::make_cons(1, boost::fusion::make_cons(1.1f));
|
||||
|
||||
BOOST_TEST((t == nf));
|
||||
BOOST_TEST((boost::fusion::tuple<int>(1) == boost::fusion::filter(nf, boost::is_same<boost::mpl::_,int>())));
|
||||
|
||||
std::cout << nf << std::endl;
|
||||
std::cout << boost::fusion::filter(nf, boost::is_same<boost::mpl::_,int>()) << std::endl;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t1(1, 'x', 3.3, s);
|
||||
tuple_iterator<2, tuple_type> pos(t1);
|
||||
|
||||
std::cout << erase(t1, pos) << std::endl;
|
||||
BOOST_TEST((erase(t1, pos) == make_tuple(1, 'x', s)));
|
||||
}
|
||||
|
||||
{
|
||||
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;
|
||||
|
||||
std::cout << erase(mpl_vec(), mpl_vec_at3()) << std::endl;
|
||||
BOOST_TEST((erase(mpl_vec(), mpl_vec_at3())
|
||||
== make_tuple(1, 2, 3, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/filter.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::mpl::vector;
|
||||
using boost::is_same;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing filter
|
||||
|
||||
X x; Y y;
|
||||
typedef tuple<Y, char, long, X, bool, double> tuple_type;
|
||||
tuple_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << filter(t, not_<is_class<_> >()) << std::endl;
|
||||
BOOST_TEST((filter(t, not_<is_class<_> >())
|
||||
== make_tuple('@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << filter(t, is_class<_>()) << std::endl;
|
||||
BOOST_TEST((filter(t, is_class<_>())
|
||||
== make_tuple(y, x)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool, double> mpl_vec;
|
||||
BOOST_TEST((filter(mpl_vec(), not_<is_class<_> >())
|
||||
== make_tuple('\0', 0, false, 0.0)));
|
||||
BOOST_TEST((filter(mpl_vec(), is_class<_>())
|
||||
== make_tuple(y, x)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<int> tuple_type;
|
||||
typedef meta::filter<tuple_type, is_class<_> >::type none_remain_type;
|
||||
BOOST_MPL_ASSERT((meta::equal_to<meta::begin<none_remain_type>::type, meta::end<none_remain_type>::type>));
|
||||
typedef meta::filter<tuple_type, not_<is_class<_> > >::type some_remain_type;
|
||||
BOOST_MPL_ASSERT_NOT((meta::equal_to<meta::begin<some_remain_type>::type, meta::end<some_remain_type>::type>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/iterator/tuple_iterator.hpp>
|
||||
#include <boost/spirit/fusion/sequence/filter_view.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.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_view
|
||||
|
||||
{ // Testing the static find_if (internal function)
|
||||
|
||||
typedef tuple<int, char, long, X> tuple_type;
|
||||
|
||||
tuple_type t(1, 'x', 987654, X());
|
||||
typedef tuple_iterator<0, tuple_type> begin;
|
||||
typedef tuple_iterator<4, tuple_type> end;
|
||||
typedef detail::static_find_if<begin, end, is_same<_, long> > filter;
|
||||
typedef filter::type type;
|
||||
|
||||
BOOST_TEST(*type(t) == 987654);
|
||||
std::cout << *type(t) << std::endl;
|
||||
std::cout << *filter::call(begin(t)) << std::endl;
|
||||
BOOST_TEST(*type(t) == *filter::call(begin(t)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<Y, char, long, X, bool, double> tuple_type;
|
||||
|
||||
X x; Y y;
|
||||
tuple_type t(y, '@', 987654, x, true, 6.6);
|
||||
filter_view<tuple_type const, not_<is_class<_> > > view(t);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST(view == make_tuple('@', 987654, true, 6.6));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/find_if.hpp>
|
||||
#include <boost/mpl/vector.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::_;
|
||||
using boost::mpl::vector;
|
||||
|
||||
/// Testing find_if
|
||||
|
||||
{
|
||||
typedef tuple<int, char, int, double> tuple_type;
|
||||
tuple_type t(12345, 'x', 678910, 3.36);
|
||||
|
||||
std::cout << *find_if(t, is_same<_, char>()) << std::endl;
|
||||
// BOOST_TEST((*find_if(t, is_same<_, char>()) == 'x'));
|
||||
|
||||
std::cout << *find_if(t, is_same<_, int>()) << std::endl;
|
||||
// BOOST_TEST((*find_if(t, is_same<_, int>()) == 12345));
|
||||
|
||||
std::cout << *find_if(t, is_same<_, double>()) << std::endl;
|
||||
// BOOST_TEST((*find_if(t, is_same<_, double>()) == 3.36));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, X, double> mpl_vec;
|
||||
// BOOST_TEST((*find_if(mpl_vec(), is_same<_, X>()) == 12345));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/find.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator int() const
|
||||
{
|
||||
return 12345;
|
||||
}
|
||||
};
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::identity;
|
||||
using boost::mpl::vector;
|
||||
|
||||
/// Testing find
|
||||
|
||||
{
|
||||
typedef tuple<int, char, int, double> tuple_type;
|
||||
tuple_type t(12345, 'x', 678910, 3.36);
|
||||
|
||||
std::cout << *boost::fusion::find(t, identity<char>()) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find(t, identity<char>()) == 'x');
|
||||
|
||||
std::cout << *boost::fusion::find(t, identity<int>()) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find(t, identity<int>()) == 12345);
|
||||
|
||||
std::cout << *boost::fusion::find(t, identity<double>()) << std::endl;
|
||||
BOOST_TEST(*boost::fusion::find(t, identity<double>()) == 3.36);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, X, double> mpl_vec;
|
||||
BOOST_TEST((*boost::fusion::find(mpl_vec(), identity<X>()) == 12345));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple10.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_size.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
#ifndef __COMO_VERSION__
|
||||
// comeau is too slow for these big tuples
|
||||
# include <boost/spirit/fusion/sequence/tuple20.hpp>
|
||||
# include <boost/spirit/fusion/sequence/tuple30.hpp>
|
||||
#if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551)
|
||||
// borland chokes on very big tuples
|
||||
# include <boost/spirit/fusion/sequence/tuple40.hpp>
|
||||
# include <boost/spirit/fusion/sequence/tuple50.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <iostream>
|
||||
#include <utility> // for std::pair
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
{
|
||||
tuple0 t;
|
||||
(void) t;
|
||||
cout << "(): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple1<int> type;
|
||||
type t;
|
||||
BOOST_STATIC_ASSERT(tuple_size<type>::value == 1);
|
||||
|
||||
BOOST_TEST(get<0>(t) == 0);
|
||||
BOOST_STATIC_ASSERT((is_same<int, tuple_element<0, type>::type>::value));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple1<int> type;
|
||||
type t(123);
|
||||
BOOST_TEST(get<0>(t) == 123);
|
||||
cout << "(int): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
tuple1<int> t1(123L); // try conversion from long to int
|
||||
tuple1<double> t2(t1); // try copy
|
||||
(void)t2;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple2<int, char> type;
|
||||
type t;
|
||||
BOOST_STATIC_ASSERT(tuple_size<type>::value == 2);
|
||||
|
||||
BOOST_TEST(get<0>(t) == 0);
|
||||
BOOST_TEST(get<1>(t) == char());
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<int, tuple_element<0, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<char, tuple_element<1, type>::type>::value));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple2<int, char> type;
|
||||
type t(123, 'x');
|
||||
BOOST_TEST(get<0>(t) == 123);
|
||||
BOOST_TEST(get<1>(t) == 'x');
|
||||
cout << "(int, char): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
tuple2<int, int> t1(123, 456);
|
||||
tuple2<double, float> t2(t1); // try copy
|
||||
tuple2<int, int> t3(std::make_pair(123, 456)); // try copy from pair
|
||||
(void)t2;
|
||||
(void)t3;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple3<int, char, double> type;
|
||||
type t;
|
||||
BOOST_STATIC_ASSERT(tuple_size<type>::value == 3);
|
||||
|
||||
BOOST_TEST(get<0>(t) == 0);
|
||||
BOOST_TEST(get<1>(t) == char());
|
||||
BOOST_TEST(get<2>(t) == double());
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<int, tuple_element<0, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<char, tuple_element<1, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<double, tuple_element<2, type>::type>::value));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple3<int, char, double> type;
|
||||
type t(123, 'x', 123.456);
|
||||
BOOST_TEST(get<0>(t) == 123);
|
||||
BOOST_TEST(get<1>(t) == 'x');
|
||||
BOOST_TEST(get<2>(t) >= 123.455 && get<2>(t) <= 123.457);
|
||||
cout << "(int, char, double): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple4<int, char, double, bool> type;
|
||||
type t(123, 'x', 123.456, true);
|
||||
cout << "(int, char, double, bool): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple4<int, char, bool, double> type;
|
||||
type t(123, 'x', true, 123.456);
|
||||
cout << "(int, char, bool, double): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple7<bool, char, short, int, long, float, double> type;
|
||||
type t(false, 'x', 3, 4, 5, 6.0, 7.0);
|
||||
|
||||
BOOST_TEST(get<0>(t) == false);
|
||||
BOOST_TEST(get<1>(t) == 'x');
|
||||
BOOST_TEST(get<2>(t) == 3);
|
||||
BOOST_TEST(get<3>(t) == 4);
|
||||
BOOST_TEST(get<4>(t) == 5);
|
||||
BOOST_TEST(get<5>(t) >= 5.9 && get<5>(t) <= 6.1);
|
||||
BOOST_TEST(get<6>(t) >= 6.9 && get<6>(t) <= 7.1);
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<bool, tuple_element<0, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<char, tuple_element<1, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<short, tuple_element<2, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<int, tuple_element<3, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<long, tuple_element<4, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<float, tuple_element<5, type>::type>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<double, tuple_element<6, type>::type>::value));
|
||||
cout << "(bool, char, short, int, long, float, double): " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple10<int, int, int, int, int, int, int, int, int, int> type;
|
||||
type t; // compile check only
|
||||
cout << "tuple10 of int: " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
#ifndef __COMO_VERSION__
|
||||
// comeau is too slow for these big tuples
|
||||
{
|
||||
typedef tuple20<
|
||||
int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int> type;
|
||||
|
||||
type t; // compile check only
|
||||
cout << "tuple20 of int: " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple30<
|
||||
int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int> type;
|
||||
|
||||
type t; // compile check only
|
||||
cout << "tuple30 of int: " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
#if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551)
|
||||
// borland chokes on very big tuples
|
||||
{
|
||||
typedef tuple40<
|
||||
int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int> type;
|
||||
|
||||
type t; // compile check only
|
||||
cout << "tuple40 of int: " << sizeof(t) << endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple50<
|
||||
int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int
|
||||
, int, int, int, int, int, int, int, int, int, int> type;
|
||||
|
||||
type t; // compile check only
|
||||
cout << "tuple50 of int: " << sizeof(t) << endl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/fold.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>
|
||||
|
||||
using boost::mpl::if_;
|
||||
using boost::mpl::int_;
|
||||
using boost::is_same;
|
||||
|
||||
struct add_ints_only
|
||||
{
|
||||
template <typename T, typename State>
|
||||
struct apply
|
||||
{
|
||||
typedef State 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, typename CountT>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
if_<
|
||||
is_same<T, int>
|
||||
, typename boost::mpl::next<CountT>::type
|
||||
, CountT
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename T, typename CountT>
|
||||
typename apply<T, CountT>::type
|
||||
operator()(T const&, CountT const&) const
|
||||
{
|
||||
typedef typename apply<T, CountT>::type result;
|
||||
return result();
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
/// Testing fold
|
||||
|
||||
{
|
||||
typedef tuple<int, char, int, double> tuple_type;
|
||||
tuple_type t(12345, 'x', 678910, 3.36);
|
||||
int result = fold(t, 0, add_ints_only());
|
||||
std::cout << result << std::endl;
|
||||
BOOST_TEST(result == 12345+678910);
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<int> tuple_type;
|
||||
tuple_type t(12345);
|
||||
|
||||
int n = fusion::fold(t, FUSION_INT(0)(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 1);
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<int, char, int, double, int> tuple_type;
|
||||
tuple_type t(12345, 'x', 678910, 3.36, 8756);
|
||||
|
||||
int n = fusion::fold(t, FUSION_INT(0)(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<int, char, int, double, int> mpl_vec;
|
||||
int n = fusion::fold(mpl_vec(), FUSION_INT(0)(), count_ints());
|
||||
std::cout << n << std::endl;
|
||||
BOOST_TEST(n == 3);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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;
|
||||
|
||||
/// Testing for_each
|
||||
|
||||
{
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t(1, 'x', 3.3, "Ruby");
|
||||
for_each(t, print());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t(1, 'x', 3.3, "Ruby");
|
||||
for_each(t, increment());
|
||||
std::cout << t << 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,45 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2004 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
|
||||
template <typename Sequence>
|
||||
struct test_sequence
|
||||
{
|
||||
typedef typename boost::mpl::begin<Sequence>::type first;
|
||||
typedef typename boost::mpl::next<first>::type second;
|
||||
typedef typename boost::mpl::next<second>::type third;
|
||||
typedef typename boost::mpl::next<third>::type fourth;
|
||||
typedef typename boost::mpl::end<Sequence>::type last;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
typename boost::mpl::deref<first>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
typename boost::mpl::deref<second>::type, float>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
typename boost::mpl::deref<third>::type, bool>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<
|
||||
typename boost::mpl::deref<fourth>::type, char>::value));
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
typedef tuple<int, float, bool, char> tuple_type;
|
||||
test_sequence<tuple_type> tuple_test;
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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 tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t1(1, 'x', 3.3, s);
|
||||
tuple_iterator<2, tuple_type> pos(t1);
|
||||
|
||||
std::cout << insert(t1, pos, 123456) << std::endl;
|
||||
BOOST_TEST((insert(t1, pos, 123456)
|
||||
== make_tuple(1, 'x', 123456, 3.3, s)));
|
||||
|
||||
std::cout << insert(t1, end(t1), 123456) << std::endl;
|
||||
BOOST_TEST((insert(t1, end(t1), 123456)
|
||||
== make_tuple(1, 'x', 3.3, s, 123456)));
|
||||
|
||||
std::cout << insert(t1, begin(t1), "glad") << std::endl;
|
||||
BOOST_TEST((insert(t1, begin(t1), "glad")
|
||||
== make_tuple(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_tuple(1, 2, 3, 66, 4, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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
|
||||
|
||||
//Needed to split insert_tests.cpp because of compiler limit in MSVC 6.5
|
||||
|
||||
{
|
||||
typedef mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
typedef mpl::begin<mpl_vec>::type mpl_vec_begin;
|
||||
typedef mpl::advance<mpl_vec_begin, mpl::int_<3> >::type mpl_vec_at3;
|
||||
|
||||
std::cout << fusion::insert(mpl_vec(), mpl_vec_at3(), mpl::int_<66>()) << std::endl;
|
||||
BOOST_TEST((fusion::insert(mpl_vec(), mpl_vec_at3(), mpl::int_<66>())
|
||||
== make_tuple(1, 2, 3, 66, 4, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#if defined BOOST_NO_STRINGSTREAM
|
||||
# include <strstream>
|
||||
#else
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
using boost::fusion::tuple;
|
||||
using boost::fusion::make_tuple;
|
||||
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_tuple(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(':');
|
||||
|
||||
// this code now works with VC6/7
|
||||
os2 << make_tuple("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_tuple(1, 2, 3);
|
||||
BOOST_TEST (os1.str() == std::string("[1,2,3][1,2,3]") );
|
||||
|
||||
std::ofstream tmp("temp.tmp");
|
||||
|
||||
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
tmp << make_tuple("One", "Two", 3);
|
||||
#endif
|
||||
tmp << tuple_delimiter(':');
|
||||
tmp << make_tuple(1000, 2000, 3000) << endl;
|
||||
|
||||
tmp.close();
|
||||
|
||||
// When teading tuples from a stream, manipulators must be set correctly:
|
||||
ifstream tmp3("temp.tmp");
|
||||
tuple<string, string, int> j;
|
||||
|
||||
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
tmp3 >> j;
|
||||
BOOST_TEST (tmp3.good() );
|
||||
#endif
|
||||
|
||||
tmp3 >> tuple_delimiter(':');
|
||||
tuple<int, int, int> i;
|
||||
tmp3 >> i;
|
||||
BOOST_TEST (tmp3.good() );
|
||||
|
||||
tmp3.close();
|
||||
|
||||
// reading tuple<int, int, int> in format (a b c);
|
||||
useThisIStringStream is("(100 200 300)");
|
||||
|
||||
tuple<int, int, int> ti;
|
||||
BOOST_TEST(bool((is >> ti) != 0));
|
||||
BOOST_TEST(ti == make_tuple(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,146 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/generate.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/joint_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.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
|
||||
|
||||
{
|
||||
tuple<int> t1(3);
|
||||
tuple<X> t2;
|
||||
typedef joint_view<tuple<int>, tuple<X> > view_type;
|
||||
view_type view(t1, t2);
|
||||
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_tuple(3, X())));
|
||||
}
|
||||
|
||||
{
|
||||
tuple<int, char> t1(3, 'x');
|
||||
tuple<X> t2;
|
||||
typedef joint_view<tuple<int, char>, tuple<X> > view_type;
|
||||
view_type view(t1, t2);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_tuple(3, 'x', X())));
|
||||
|
||||
*begin(view) = 4;
|
||||
BOOST_TEST(get<0>(t1) == 4);
|
||||
}
|
||||
|
||||
{
|
||||
tuple<int, char> t1(3, 'x');
|
||||
tuple<X, int> t2;
|
||||
typedef joint_view<tuple<int, char>, tuple<X, int> > view_type;
|
||||
view_type view(t1, t2);
|
||||
std::cout << view << std::endl;
|
||||
BOOST_TEST((view == make_tuple(3, 'x', X(), 0)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple<int> t1_type;
|
||||
t1_type t1(777);
|
||||
typedef tuple<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_tuple(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_tuple(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_tuple(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_tuple(1, 'x', 3.3, 777, 777, 1, 'x', 3.3));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<tuple<>, t1_type> jt_type;
|
||||
tuple<> empty;
|
||||
jt_type jt(empty, t1);
|
||||
std::cout << generate(jt) << std::endl;
|
||||
BOOST_TEST(generate(jt) == make_tuple(777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t1_type, tuple<> > jt_type;
|
||||
tuple<> empty;
|
||||
jt_type jt(t1, empty);
|
||||
std::cout << generate(jt) << std::endl;
|
||||
BOOST_TEST(generate(jt) == make_tuple(777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<tuple<>, tuple<> > jt_type;
|
||||
tuple<> empty;
|
||||
jt_type jt(empty, empty);
|
||||
std::cout << generate(jt) << std::endl;
|
||||
BOOST_TEST(generate(jt) == make_tuple());
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/generate.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/joint_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.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
|
||||
{
|
||||
typedef tuple<int> t1_type;
|
||||
t1_type t1(777);
|
||||
typedef tuple<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_tuple(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_tuple(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_tuple(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_tuple(1, 'x', 3.3, 777, 777, 1, 'x', 3.3));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<tuple<>, t1_type> jt_type;
|
||||
tuple<> empty;
|
||||
jt_type jt(empty, t1);
|
||||
std::cout << generate(jt) << std::endl;
|
||||
BOOST_TEST(generate(jt) == make_tuple(777));
|
||||
}
|
||||
|
||||
{
|
||||
typedef joint_view<t1_type, tuple<> > jt_type;
|
||||
tuple<> empty;
|
||||
jt_type jt(t1, empty);
|
||||
std::cout << generate(jt) << std::endl;
|
||||
BOOST_TEST(generate(jt) == make_tuple(777));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
// something to prevent warnings for unused variables
|
||||
template<class T> void dummy(const T&) {}
|
||||
|
||||
class A {};
|
||||
class B {};
|
||||
}
|
||||
|
||||
void make_tuple_test() {}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{
|
||||
tuple<int, char> t1 = make_tuple(5, 'a');
|
||||
BOOST_TEST(get<0>(t1) == 5);
|
||||
BOOST_TEST(get<1>(t1) == 'a');
|
||||
|
||||
tuple<int, std::string> t2;
|
||||
t2 = make_tuple((short int)2, std::string("Hi"));
|
||||
BOOST_TEST(get<0>(t2) == 2);
|
||||
BOOST_TEST(get<1>(t2) == "Hi");
|
||||
}
|
||||
|
||||
{ // This test was previously disallowed for non-PTS compilers.
|
||||
A a = A(); B b;
|
||||
const A ca = a;
|
||||
make_tuple(boost::cref(a), b);
|
||||
make_tuple(boost::ref(a), b);
|
||||
make_tuple(boost::ref(a), boost::cref(b));
|
||||
make_tuple(boost::ref(ca));
|
||||
}
|
||||
|
||||
{ // the result of make_tuple is assignable:
|
||||
BOOST_TEST(make_tuple(2, 4, 6) ==
|
||||
(make_tuple(1, 2, 3) = make_tuple(2, 4, 6)));
|
||||
}
|
||||
|
||||
{ // This test was previously disallowed for non-PTS compilers.
|
||||
make_tuple("Donald", "Daisy"); // should work;
|
||||
// std::make_pair("Doesn't","Work"); // fails
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||
{ // This test works on VC7 now, only VC6 fails
|
||||
// You can store a reference to a function in a tuple
|
||||
tuple<void(&)()> adf(make_tuple_test);
|
||||
dummy(adf); // avoid warning for unused variable
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
// But make_tuple doesn't work
|
||||
// with function references, since it creates a const
|
||||
// qualified function type
|
||||
|
||||
// make_tuple(make_tuple_test);
|
||||
}
|
||||
|
||||
{
|
||||
// With function pointers, make_tuple works just fine
|
||||
// This test works on Borland now
|
||||
|
||||
make_tuple(&make_tuple_test);
|
||||
}
|
||||
|
||||
// NOTE:
|
||||
//
|
||||
// wrapping the function reference with ref helps on gcc 2.95.2.
|
||||
// on edg 2.43. it results in a catastrophic error?
|
||||
|
||||
// make_tuple(ref(foo3));
|
||||
|
||||
// It seems that edg can't use implicitly the ref's conversion operator, e.g.:
|
||||
// typedef void (&func_t) (void);
|
||||
// func_t fref = static_cast<func_t>(ref(make_tuple_test)); // works fine
|
||||
// func_t fref = ref(make_tuple_test); // error
|
||||
|
||||
// This is probably not a very common situation, so currently
|
||||
// I don't know how which compiler is right (JJ)
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_size.hpp>
|
||||
#include <boost/spirit/fusion/sequence/is_sequence.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
{ // testing const tuples
|
||||
|
||||
const tuple<int, float> t1(5, 3.3f);
|
||||
BOOST_TEST(get<0>(t1) == 5);
|
||||
BOOST_TEST(get<1>(t1) == 3.3f);
|
||||
}
|
||||
|
||||
{ // testing length
|
||||
|
||||
typedef tuple<int, float, double> t1;
|
||||
typedef tuple<> t2;
|
||||
|
||||
BOOST_STATIC_ASSERT(tuple_size<t1>::value == 3);
|
||||
BOOST_STATIC_ASSERT(tuple_size<t2>::value == 0);
|
||||
}
|
||||
|
||||
{ // testing is_sequence
|
||||
|
||||
typedef tuple<int, float, double> t1;
|
||||
typedef tuple<> t2;
|
||||
typedef tuple<char> t3;
|
||||
|
||||
BOOST_STATIC_ASSERT(is_sequence<t1>::value);
|
||||
BOOST_STATIC_ASSERT(is_sequence<t2>::value);
|
||||
BOOST_STATIC_ASSERT(is_sequence<t3>::value);
|
||||
BOOST_STATIC_ASSERT(!is_sequence<int>::value);
|
||||
BOOST_STATIC_ASSERT(!is_sequence<char>::value);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_size.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
BOOST_MPL_ASSERT_RELATION((tuple_size<std::pair<int,float> >::value),==,2);
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<tuple_element<0, std::pair<int, float> >::type, int>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<tuple_element<1, std::pair<int, float> >::type, float>));
|
||||
|
||||
std::pair<int, std::string> pr(1, "hello");
|
||||
BOOST_TEST(get<0>(pr) == 1);
|
||||
BOOST_TEST(get<1>(pr) == "hello");
|
||||
|
||||
get<0>(pr) = 2;
|
||||
get<1>(pr) = "world";
|
||||
BOOST_TEST(get<0>(pr) == 2);
|
||||
BOOST_TEST(get<1>(pr) == "world");
|
||||
|
||||
const std::pair<int, std::string> pr2(pr);
|
||||
BOOST_TEST(get<0>(pr2) == 2);
|
||||
BOOST_TEST(get<1>(pr2) == "world");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/push_back.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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 tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, 123456) << std::endl;
|
||||
BOOST_TEST((push_back(t1, 123456)
|
||||
== make_tuple(1, 'x', 3.3, s, 123456)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, "funny") << std::endl;
|
||||
BOOST_TEST((push_back(t1, "funny")
|
||||
== make_tuple(1, 'x', 3.3, s, std::string("funny"))));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_back(t1, t1) << std::endl;
|
||||
BOOST_TEST((push_back(t1, t1)
|
||||
== make_tuple(1, 'x', 3.3, s, t1)));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// This is OK -- can modify a tuple in place
|
||||
tuple<int,int,int> i(1,2,3);
|
||||
std::cout << i << '\n';
|
||||
for_each(i, plus_one());
|
||||
std::cout << i << '\n';
|
||||
|
||||
// This should also be OK -- can modify a fusion sequence in place
|
||||
typedef tuple<> T1;
|
||||
typedef meta::push_back<T1, int>::type T2;
|
||||
typedef meta::push_back<T2, int>::type T3;
|
||||
typedef meta::push_back<T3, int>::type T4;
|
||||
|
||||
T1 t1 = T1();
|
||||
T2 t2 = push_back(t1, 1);
|
||||
T3 t3 = push_back(t2, 2);
|
||||
T4 t4 = push_back(t3, 3);
|
||||
|
||||
std::cout << "=============\n";
|
||||
std::cout << t4 << std::endl;
|
||||
for_each(t4, plus_one());
|
||||
std::cout << "=============\n";
|
||||
std::cout << t4 << std::endl;
|
||||
|
||||
BOOST_TEST(t4 == make_tuple(2, 3, 4));
|
||||
}
|
||||
|
||||
{
|
||||
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_tuple(1, 2, 3, 4, 5, 6)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/push_back.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_back
|
||||
|
||||
|
||||
{
|
||||
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_tuple(1, 2, 3, 4, 5, 6)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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 tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
std::cout << push_front(t1, 123456) << std::endl;
|
||||
BOOST_TEST((push_front(t1, 123456)
|
||||
== make_tuple(123456, 1, 'x', 3.3, s)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << push_front(t1, "lively") << std::endl;
|
||||
BOOST_TEST((push_front(t1, "lively")
|
||||
== make_tuple(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_tuple(1, 2, 3, 4, 5, 6)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/range.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing range
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t1(1, 'x', 3.3, s);
|
||||
|
||||
{
|
||||
typedef tuple_iterator<1, tuple_type> i1t;
|
||||
typedef tuple_iterator<3, tuple_type> i3t;
|
||||
|
||||
i1t i1(t1);
|
||||
i3t i3(t1);
|
||||
|
||||
range<i1t, i3t> slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST(slice == make_tuple('x', 3.3));
|
||||
}
|
||||
|
||||
{
|
||||
typedef tuple_iterator<0, tuple_type> i1t;
|
||||
typedef tuple_iterator<0, tuple_type> i3t;
|
||||
|
||||
i1t i1(t1);
|
||||
i3t i3(t1);
|
||||
|
||||
range<i1t, i3t> slice(i1, i3);
|
||||
std::cout << slice << std::endl;
|
||||
BOOST_TEST(slice == tuple<>());
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/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;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing remove_if
|
||||
|
||||
X x; Y y;
|
||||
typedef tuple<Y, char, long, X, bool, double> tuple_type;
|
||||
tuple_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << remove_if(t, not_<is_class<_> >()) << std::endl;
|
||||
BOOST_TEST((remove_if(t, not_<is_class<_> >())
|
||||
== make_tuple(y, x)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << remove_if(t, is_class<_>()) << std::endl;
|
||||
BOOST_TEST((remove_if(t, is_class<_>())
|
||||
== make_tuple('@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool, double> mpl_vec;
|
||||
BOOST_TEST((remove_if(mpl_vec(), not_<is_class<_> >())
|
||||
== tuple<Y, X>()));
|
||||
BOOST_TEST((remove_if(mpl_vec(), is_class<_>())
|
||||
== tuple<char, long, bool, double>()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/remove.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/identity.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 tuple<Y, char, long, X, bool, double> tuple_type;
|
||||
tuple_type t(y, '@', 987654, x, true, 6.6);
|
||||
|
||||
{
|
||||
std::cout << fusion::remove(t, identity<X>()) << std::endl;
|
||||
BOOST_TEST((fusion::remove(t, identity<X>())
|
||||
== make_tuple(y, '@', 987654, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << fusion::remove(t, identity<Y>()) << std::endl;
|
||||
BOOST_TEST((fusion::remove(t, identity<Y>())
|
||||
== make_tuple('@', 987654, x, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << fusion::remove(t, identity<long>()) << std::endl;
|
||||
BOOST_TEST((fusion::remove(t, identity<long>())
|
||||
== make_tuple(y, '@', x, true, 6.6)));
|
||||
}
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool, double> mpl_vec;
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<X>())
|
||||
== tuple<Y, char, long, bool, double>()));
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<Y>())
|
||||
== tuple<char, long, X, bool, double>()));
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<long>())
|
||||
== tuple<Y, char, X, bool, double>()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/remove.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/identity.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
|
||||
|
||||
{
|
||||
typedef vector<Y, char, long, X, bool, double> mpl_vec;
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<X>())
|
||||
== tuple<Y, char, long, bool, double>()));
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<Y>())
|
||||
== tuple<char, long, X, bool, double>()));
|
||||
BOOST_TEST((fusion::remove(mpl_vec(), identity<long>())
|
||||
== tuple<Y, char, X, bool, double>()));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/iterator/tuple_iterator.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/replace.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 mpl = boost::mpl;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing replace
|
||||
|
||||
{
|
||||
char const* s = "Ruby";
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t(1, 'x', 3.3, s);
|
||||
tuple_iterator<2, tuple_type> pos(t);
|
||||
|
||||
std::cout << replace(t, pos, 123456) << std::endl;
|
||||
BOOST_TEST((replace(t, pos, 123456)
|
||||
== make_tuple(1, 'x', 123456, s)));
|
||||
|
||||
std::cout << replace(t, begin(t), "happy") << std::endl;
|
||||
BOOST_TEST((replace(t, begin(t), "happy")
|
||||
== make_tuple(std::string("happy"), '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 << replace(mpl_vec(), mpl_vec_at3(), int_<66>()) << std::endl;
|
||||
BOOST_TEST((replace(mpl_vec(), mpl_vec_at3(), int_<66>())
|
||||
== make_tuple(1, 2, 3, 66, 5)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/single_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
|
||||
struct X {};
|
||||
|
||||
template <typename OS>
|
||||
OS& operator<<(OS& os, X const&)
|
||||
{
|
||||
os << "<X-object>";
|
||||
return os;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing single_view
|
||||
|
||||
{
|
||||
single_view<int> view1(3);
|
||||
std::cout << view1 << std::endl;
|
||||
|
||||
// allow single_view element to be modified
|
||||
*begin(view1) += 4;
|
||||
std::cout << view1 << std::endl;
|
||||
BOOST_TEST(*begin(view1) == 7);
|
||||
BOOST_TEST(view1.val == 7);
|
||||
|
||||
single_view<X> view2;
|
||||
std::cout << view2 << std::endl;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tie.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
// 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;
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
int a;
|
||||
char b;
|
||||
foo c(5);
|
||||
|
||||
tie(a, b, c) = make_tuple(2, 'a', foo(3));
|
||||
BOOST_TEST(a == 2);
|
||||
BOOST_TEST(b == 'a');
|
||||
BOOST_TEST(c == foo(3));
|
||||
|
||||
tie(a, ignore, c) = make_tuple((short int)5, false, foo(5));
|
||||
BOOST_TEST(a == 5);
|
||||
BOOST_TEST(b == 'a');
|
||||
BOOST_TEST(c == foo(5));
|
||||
|
||||
// testing assignment from std::pair
|
||||
int i, j;
|
||||
tie (i, j) = std::make_pair(1, 2);
|
||||
BOOST_TEST(i == 1 && j == 2);
|
||||
|
||||
tuple<int, int, float> ta;
|
||||
|
||||
#ifdef E11
|
||||
ta = std::make_pair(1, 2); // should fail, tuple is of length 3, not 2
|
||||
#endif
|
||||
|
||||
dummy(ta);
|
||||
|
||||
// ties cannot be rebound
|
||||
int d = 3;
|
||||
tuple<int&> ti(a);
|
||||
BOOST_TEST(&get<0>(ti) == &a);
|
||||
ti = tuple<int&>(d);
|
||||
BOOST_TEST(&get<0>(ti) == &a);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/type_sequence.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/transform.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
|
||||
#include <boost/spirit/fusion/sequence/generate.hpp>
|
||||
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
|
||||
struct square
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct apply
|
||||
{
|
||||
BOOST_STATIC_ASSERT(!boost::is_reference<T>::value);
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int operator()(T x) const
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
};
|
||||
|
||||
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> mpl_list1;
|
||||
typedef type_sequence<mpl_list1> sequence_type;
|
||||
sequence_type sequence;
|
||||
|
||||
std::cout << transform(sequence, square()) << std::endl;
|
||||
BOOST_TEST((transform(sequence, square()) == make_tuple(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_tuple(25, 36, 49, 64)));
|
||||
}
|
||||
|
||||
{
|
||||
tuple<int, int, int> tup(1, 2, 3);
|
||||
std::cout << transform(tup, square()) << std::endl;
|
||||
BOOST_TEST((transform(tup, square()) == make_tuple(1, 4, 9)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/transform_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/type_sequence.hpp>
|
||||
#include <boost/mpl/range_c.hpp>
|
||||
|
||||
struct square
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int operator()(T x) const
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing the transform_view
|
||||
|
||||
{
|
||||
typedef boost::mpl::range_c<int, 5, 9> mpl_list1;
|
||||
typedef type_sequence<mpl_list1> sequence_type;
|
||||
sequence_type sequence;
|
||||
transform_view<sequence_type, square> xform(sequence, square());
|
||||
|
||||
std::cout << xform << std::endl;
|
||||
BOOST_TEST((xform == make_tuple(25, 36, 49, 64)));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/not_equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/less.hpp>
|
||||
#include <boost/spirit/fusion/sequence/less_equal.hpp>
|
||||
#include <boost/spirit/fusion/sequence/greater.hpp>
|
||||
#include <boost/spirit/fusion/sequence/greater_equal.hpp>
|
||||
|
||||
void
|
||||
equality_test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int, char> t1(5, 'a');
|
||||
tuple<int, char> t2(5, 'a');
|
||||
BOOST_TEST(t1 == t2);
|
||||
|
||||
tuple<int, char> t3(5, 'b');
|
||||
tuple<int, char> t4(2, 'a');
|
||||
BOOST_TEST(t1 != t3);
|
||||
BOOST_TEST(t1 != t4);
|
||||
BOOST_TEST(!(t1 != t2));
|
||||
}
|
||||
|
||||
void
|
||||
ordering_test()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int, float> t1(4, 3.3f);
|
||||
tuple<short, float> t2(5, 3.3f);
|
||||
tuple<long, double> t3(5, 4.4);
|
||||
BOOST_TEST(t1 < t2);
|
||||
BOOST_TEST(t1 <= t2);
|
||||
BOOST_TEST(t2 > t1);
|
||||
BOOST_TEST(t2 >= t1);
|
||||
BOOST_TEST(t2 < t3);
|
||||
BOOST_TEST(t2 <= t3);
|
||||
BOOST_TEST(t3 > t2);
|
||||
BOOST_TEST(t3 >= t2);
|
||||
}
|
||||
|
||||
void extended_tests()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
typedef tuple<char,int> test_tuple;
|
||||
const test_tuple a0('a',0), a1('a',1), a2('a',2),
|
||||
b0('b',0), b1('b',1), b2('b',2),
|
||||
c0('c',0), c1('c',1), c2('c',2);
|
||||
|
||||
BOOST_TEST(b1 == b1);
|
||||
BOOST_TEST(!(b1 == a0));
|
||||
BOOST_TEST(!(b1 == a1));
|
||||
BOOST_TEST(!(b1 == a2));
|
||||
BOOST_TEST(!(b1 == b0));
|
||||
BOOST_TEST(!(b1 == b2));
|
||||
BOOST_TEST(!(b1 == c0));
|
||||
BOOST_TEST(!(b1 == c1));
|
||||
BOOST_TEST(!(b1 == c2));
|
||||
BOOST_TEST(!(a0 == b1));
|
||||
BOOST_TEST(!(a1 == b1));
|
||||
BOOST_TEST(!(a2 == b1));
|
||||
BOOST_TEST(!(b0 == b1));
|
||||
BOOST_TEST(!(b2 == b1));
|
||||
BOOST_TEST(!(c0 == b1));
|
||||
BOOST_TEST(!(c1 == b1));
|
||||
BOOST_TEST(!(c2 == b1));
|
||||
|
||||
BOOST_TEST(!(b1 != b1));
|
||||
BOOST_TEST(b1 != a0);
|
||||
BOOST_TEST(b1 != a1);
|
||||
BOOST_TEST(b1 != a2);
|
||||
BOOST_TEST(b1 != b0);
|
||||
BOOST_TEST(b1 != b2);
|
||||
BOOST_TEST(b1 != c0);
|
||||
BOOST_TEST(b1 != c1);
|
||||
BOOST_TEST(b1 != c2);
|
||||
BOOST_TEST(a0 != b1);
|
||||
BOOST_TEST(a1 != b1);
|
||||
BOOST_TEST(a2 != b1);
|
||||
BOOST_TEST(b0 != b1);
|
||||
BOOST_TEST(b2 != b1);
|
||||
BOOST_TEST(c0 != b1);
|
||||
BOOST_TEST(c1 != b1);
|
||||
BOOST_TEST(c2 != b1);
|
||||
|
||||
BOOST_TEST(!(b1 < b1));
|
||||
BOOST_TEST(!(b1 < a0));
|
||||
BOOST_TEST(!(b1 < a1));
|
||||
BOOST_TEST(!(b1 < a2));
|
||||
BOOST_TEST(!(b1 < b0));
|
||||
BOOST_TEST(b1 < b2);
|
||||
BOOST_TEST(b1 < c0);
|
||||
BOOST_TEST(b1 < c1);
|
||||
BOOST_TEST(b1 < c2);
|
||||
BOOST_TEST(a0 < b1);
|
||||
BOOST_TEST(a1 < b1);
|
||||
BOOST_TEST(a2 < b1);
|
||||
BOOST_TEST(b0 < b1);
|
||||
BOOST_TEST(!(b2 < b1));
|
||||
BOOST_TEST(!(c0 < b1));
|
||||
BOOST_TEST(!(c1 < b1));
|
||||
BOOST_TEST(!(c2 < b1));
|
||||
|
||||
BOOST_TEST(b1 <= b1);
|
||||
BOOST_TEST(!(b1 <= a0));
|
||||
BOOST_TEST(!(b1 <= a1));
|
||||
BOOST_TEST(!(b1 <= a2));
|
||||
BOOST_TEST(!(b1 <= b0));
|
||||
BOOST_TEST(b1 <= b2);
|
||||
BOOST_TEST(b1 <= c0);
|
||||
BOOST_TEST(b1 <= c1);
|
||||
BOOST_TEST(b1 <= c2);
|
||||
BOOST_TEST(a0 <= b1);
|
||||
BOOST_TEST(a1 <= b1);
|
||||
BOOST_TEST(a2 <= b1);
|
||||
BOOST_TEST(b0 <= b1);
|
||||
BOOST_TEST(!(b2 <= b1));
|
||||
BOOST_TEST(!(c0 <= b1));
|
||||
BOOST_TEST(!(c1 <= b1));
|
||||
BOOST_TEST(!(c2 <= b1));
|
||||
|
||||
BOOST_TEST(!(b1 > b1));
|
||||
BOOST_TEST(b1 > a0);
|
||||
BOOST_TEST(b1 > a1);
|
||||
BOOST_TEST(b1 > a2);
|
||||
BOOST_TEST(b1 > b0);
|
||||
BOOST_TEST(!(b1 > b2));
|
||||
BOOST_TEST(!(b1 > c0));
|
||||
BOOST_TEST(!(b1 > c1));
|
||||
BOOST_TEST(!(b1 > c2));
|
||||
BOOST_TEST(!(a0 > b1));
|
||||
BOOST_TEST(!(a1 > b1));
|
||||
BOOST_TEST(!(a2 > b1));
|
||||
BOOST_TEST(!(b0 > b1));
|
||||
BOOST_TEST(b2 > b1);
|
||||
BOOST_TEST(c0 > b1);
|
||||
BOOST_TEST(c1 > b1);
|
||||
BOOST_TEST(c2 > b1);
|
||||
|
||||
BOOST_TEST(b1 >= b1);
|
||||
BOOST_TEST(b1 >= a0);
|
||||
BOOST_TEST(b1 >= a1);
|
||||
BOOST_TEST(b1 >= a2);
|
||||
BOOST_TEST(b1 >= b0);
|
||||
BOOST_TEST(!(b1 >= b2));
|
||||
BOOST_TEST(!(b1 >= c0));
|
||||
BOOST_TEST(!(b1 >= c1));
|
||||
BOOST_TEST(!(b1 >= c2));
|
||||
BOOST_TEST(!(a0 >= b1));
|
||||
BOOST_TEST(!(a1 >= b1));
|
||||
BOOST_TEST(!(a2 >= b1));
|
||||
BOOST_TEST(!(b0 >= b1));
|
||||
BOOST_TEST(b2 >= b1);
|
||||
BOOST_TEST(c0 >= b1);
|
||||
BOOST_TEST(c1 >= b1);
|
||||
BOOST_TEST(c2 >= b1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
equality_test();
|
||||
ordering_test();
|
||||
extended_tests();
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
// 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) {}
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int> t1;
|
||||
BOOST_TEST(get<0>(t1) == int());
|
||||
|
||||
tuple<float> t2(5.5f);
|
||||
BOOST_TEST(get<0>(t2) > 5.4f && get<0>(t2) < 5.6f);
|
||||
|
||||
tuple<foo> t3(foo(12));
|
||||
BOOST_TEST(get<0>(t3) == foo(12));
|
||||
|
||||
tuple<double> t4(t2);
|
||||
BOOST_TEST(get<0>(t4) > 5.4 && get<0>(t4) < 5.6);
|
||||
|
||||
tuple<int, float> t5;
|
||||
BOOST_TEST(get<0>(t5) == int());
|
||||
BOOST_TEST(get<1>(t5) == float());
|
||||
|
||||
tuple<int, float> t6(12, 5.5f);
|
||||
BOOST_TEST(get<0>(t6) == 12);
|
||||
BOOST_TEST(get<1>(t6) > 5.4f && get<1>(t6) < 5.6f);
|
||||
|
||||
tuple<int, float> t7(t6);
|
||||
BOOST_TEST(get<0>(t7) == 12);
|
||||
BOOST_TEST(get<1>(t7) > 5.4f && get<1>(t7) < 5.6f);
|
||||
|
||||
tuple<long, double> t8(t6);
|
||||
BOOST_TEST(get<0>(t8) == 12);
|
||||
BOOST_TEST(get<1>(t8) > 5.4f && get<1>(t8) < 5.6f);
|
||||
|
||||
dummy
|
||||
(
|
||||
tuple<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(tuple<int, double>());
|
||||
dummy(tuple<int, double>(1,3.14));
|
||||
|
||||
// dummy(tuple<double&>()); // should fail, no defaults for references
|
||||
// dummy(tuple<const double&>()); // likewise
|
||||
|
||||
{ // JDG 10-21-2003: previously not availiable without
|
||||
// partial template specialization. Now OK with VC6/7
|
||||
|
||||
double dd = 5;
|
||||
dummy(tuple<double&>(dd)); // ok
|
||||
dummy(tuple<const double&>(dd+3.14)); // ok, but dangerous
|
||||
}
|
||||
|
||||
// dummy(tuple<double&>(dd+3.14)); // should fail,
|
||||
// // temporary to non-const reference
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
// 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(); }; };
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int, char> t1(4, 'a');
|
||||
tuple<int, char> t2(5, 'b');
|
||||
t2 = t1;
|
||||
BOOST_TEST(get<0>(t1) == get<0>(t2));
|
||||
BOOST_TEST(get<1>(t1) == get<1>(t2));
|
||||
|
||||
tuple<long, std::string> t3(2, "a");
|
||||
t3 = t1;
|
||||
BOOST_TEST((double)get<0>(t1) == get<0>(t3));
|
||||
BOOST_TEST(get<1>(t1) == get<1>(t3)[0]);
|
||||
|
||||
// testing copy and assignment with implicit conversions
|
||||
// between elements testing tie
|
||||
|
||||
tuple<char, BB*, BB, DD> t;
|
||||
tuple<int, AA*, CC, CC> a(t);
|
||||
a = t;
|
||||
|
||||
int i; char c; double d;
|
||||
tuple<int&, char&, double&>(i, c, d) = tuple<int, char, double>(1, 'a', 5.5);
|
||||
|
||||
BOOST_TEST(i==1);
|
||||
BOOST_TEST(c=='a');
|
||||
BOOST_TEST(d>5.4 && d<5.6);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
// something to prevent warnings for unused variables
|
||||
template<class T> void dummy(const T&) {}
|
||||
|
||||
class A {};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
// JDG 10-21-2003: previously not availiable without
|
||||
// partial template specialization. Now OK with VC6/7
|
||||
|
||||
double d = 2.7;
|
||||
A a;
|
||||
tuple<int, double&, const A&, int> t(1, d, a, 2);
|
||||
const tuple<int, double&, const A, int> ct(t);
|
||||
|
||||
int i = get<0>(t);
|
||||
int i2 = get<3>(t);
|
||||
|
||||
BOOST_TEST(i == 1 && i2 == 2);
|
||||
|
||||
int j = get<0>(ct);
|
||||
BOOST_TEST(j == 1);
|
||||
|
||||
get<0>(t) = 5;
|
||||
BOOST_TEST(get<0>(t) == 5);
|
||||
|
||||
// get<0>(ct) = 5; // can't assign to const
|
||||
|
||||
double e = get<1>(t);
|
||||
BOOST_TEST(e > 2.69 && e < 2.71);
|
||||
|
||||
get<1>(t) = 3.14+i;
|
||||
BOOST_TEST(get<1>(t) > 4.13 && get<1>(t) < 4.15);
|
||||
|
||||
// get<4>(t) = A(); // can't assign to const
|
||||
// dummy(get<5>(ct)); // illegal index
|
||||
|
||||
++get<0>(t);
|
||||
BOOST_TEST(get<0>(t) == 6);
|
||||
|
||||
BOOST_STATIC_ASSERT(!(
|
||||
boost::is_const<tuple_element<0, tuple<int, float> >::type>::value));
|
||||
|
||||
// constness should not affect
|
||||
BOOST_STATIC_ASSERT(!(
|
||||
boost::is_const<tuple_element<0, const tuple<int, float> >::type>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT(!(
|
||||
boost::is_const<tuple_element<1, tuple<int, float> >::type>::value));
|
||||
|
||||
// constness should not affect
|
||||
BOOST_STATIC_ASSERT(!(
|
||||
boost::is_const<tuple_element<1, const tuple<int, float> >::type>::value));
|
||||
|
||||
dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2003 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)
|
||||
==============================================================================*/
|
||||
#include <iostream>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/iterator/tuple_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/prior.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
//#include <boost/spirit/fusion/distance.hpp>
|
||||
//#include <boost/spirit/fusion/advance.hpp>
|
||||
//#include <boost/spirit/fusion/get_pointer.hpp>
|
||||
//#include <boost/spirit/fusion/value_of.hpp>
|
||||
//#include <boost/spirit/fusion/pointer_of.hpp>
|
||||
//#include <boost/spirit/fusion/reference_of.hpp>
|
||||
//#include <boost/spirit/fusion/is_readable.hpp>
|
||||
//#include <boost/spirit/fusion/is_writable.hpp>
|
||||
//#include <boost/spirit/fusion/category_of.hpp>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using namespace boost;
|
||||
|
||||
/// Testing the tuple_iterator
|
||||
|
||||
{ // testing deref, next, prior, begin, end
|
||||
|
||||
char const* s = "Hello";
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
tuple_type t(1, 'x', 3.3, s);
|
||||
tuple_iterator<0, tuple_type> i(t);
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||
// ?%$# VC6 I don't know why this is needed! $$$LOOK$$$
|
||||
//This is no longer needed...
|
||||
//next(i);
|
||||
#endif
|
||||
|
||||
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_COMPILE_FAIL
|
||||
next(next(next(next(next(i))))); // past the end: must not compile
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
BOOST_TEST(*begin(t) == 1);
|
||||
BOOST_TEST(*prior(end(t)) == s);
|
||||
|
||||
*i = 3;
|
||||
BOOST_TEST(*i == 3);
|
||||
BOOST_TEST(*i == get<0>(t));
|
||||
}
|
||||
|
||||
{ // Testing const tuple and const tuple_iterator
|
||||
|
||||
char const* s = "Hello";
|
||||
typedef tuple<int, char, double, char const*> const tuple_type;
|
||||
tuple_type t(1, 'x', 3.3, s);
|
||||
tuple_iterator<0, tuple_type> i(t);
|
||||
|
||||
BOOST_TEST(*i == 1);
|
||||
BOOST_TEST(*next(i) == 'x');
|
||||
BOOST_TEST(*begin(t) == 1);
|
||||
BOOST_TEST(*prior(end(t)) == s);
|
||||
|
||||
#ifdef FUSION_TEST_COMPILE_FAIL
|
||||
*i = 3; // must not compile
|
||||
#endif
|
||||
}
|
||||
|
||||
{ // Testing tuple equality
|
||||
|
||||
typedef tuple<int, char, double, char const*> tuple_type;
|
||||
typedef tuple_iterator<0, tuple_type> ti1;
|
||||
typedef tuple_iterator<0, tuple_type const> ti2;
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti1>::value));
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti1 const>::value));
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti2>::value));
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti2>::value));
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti2 const>::value));
|
||||
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti2 const>::value));
|
||||
}
|
||||
//
|
||||
// { // Testing distance
|
||||
//
|
||||
// typedef tuple<int, char, double, char const*> tuple_type;
|
||||
// tuple_type t(1, 'x', 3.3, "Hello");
|
||||
//
|
||||
// BOOST_STATIC_ASSERT((result_of_distance<
|
||||
// tuple_iterator<0, tuple_type>
|
||||
// , tuple_iterator<4, tuple_type> >::type::value == 4));
|
||||
//
|
||||
// BOOST_TEST(distance(begin(t), end(t)).value == 4);
|
||||
// }
|
||||
//
|
||||
// { // Testing advance
|
||||
//
|
||||
// typedef tuple<int, char, double, char const*> tuple_type;
|
||||
// tuple_type t(1, 'x', 3.3, "Hello");
|
||||
//
|
||||
// BOOST_TEST(*advance<0>(begin(t)) == get<0>(t));
|
||||
// BOOST_TEST(*advance<1>(begin(t)) == get<1>(t));
|
||||
// BOOST_TEST(*advance<2>(begin(t)) == get<2>(t));
|
||||
// BOOST_TEST(*advance<3>(begin(t)) == get<3>(t));
|
||||
//
|
||||
// BOOST_TEST(*advance<-1>(end(t)) == get<3>(t));
|
||||
// BOOST_TEST(*advance<-2>(end(t)) == get<2>(t));
|
||||
// BOOST_TEST(*advance<-3>(end(t)) == get<1>(t));
|
||||
// BOOST_TEST(*advance<-4>(end(t)) == get<0>(t));
|
||||
//
|
||||
// BOOST_TEST(&*advance<0>(begin(t)) == &get<0>(t));
|
||||
// BOOST_TEST(&*advance<1>(begin(t)) == &get<1>(t));
|
||||
// BOOST_TEST(&*advance<2>(begin(t)) == &get<2>(t));
|
||||
// BOOST_TEST(&*advance<3>(begin(t)) == &get<3>(t));
|
||||
// }
|
||||
//
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
|
||||
// #$%&@ Borland IS SO DUMB!!! #$%&@
|
||||
{
|
||||
typedef tuple<int, int> tuple_type;
|
||||
typedef meta::begin<tuple_type>::type begin_type;
|
||||
typedef meta::end<tuple_type>::type end_type;
|
||||
typedef meta::next<begin_type>::type i1;
|
||||
typedef meta::next<i1>::type i2;
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<end_type, i2>::value));
|
||||
}
|
||||
#endif
|
||||
|
||||
{ // Testing constructing tuples from iterators
|
||||
|
||||
tuple<int, char, double> t1(1, 'x', 3.3);
|
||||
|
||||
tuple<long, int, double> t2(begin(t1));
|
||||
BOOST_TEST(get<0>(t2) == get<0>(t1));
|
||||
BOOST_TEST(get<1>(t2) == get<1>(t1));
|
||||
BOOST_TEST(get<2>(t2) == get<2>(t1));
|
||||
|
||||
tuple<char, double> t3(next(begin(t1)));
|
||||
BOOST_TEST(get<0>(t3) == get<1>(t1));
|
||||
BOOST_TEST(get<1>(t3) == get<2>(t1));
|
||||
|
||||
tuple<double> t4(prior(end(t1)));
|
||||
BOOST_TEST(get<0>(t4) == get<2>(t1));
|
||||
|
||||
tuple<char, char, char, char, char, char, char, char, char> t5;
|
||||
tuple<int, int, int, int, int, int, int, int, int> t6(begin(t5));
|
||||
(void)t6;
|
||||
}
|
||||
|
||||
{ // Testing tuple iterator value, reference, pointer, is_readable,
|
||||
// is_writable, meta::deref, result_of_get_pointer
|
||||
|
||||
typedef tuple<int, char&> tuple_type;
|
||||
typedef tuple_iterator<0, tuple_type> i0;
|
||||
typedef tuple_iterator<1, tuple_type> i1;
|
||||
typedef tuple_iterator<1, tuple_type const> i2;
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<tuple_element<0, tuple_type>::type, int>::value));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<tuple_element<1, tuple_type>::type, char&>::value));
|
||||
|
||||
// BOOST_STATIC_ASSERT((
|
||||
// is_same<category_of<i0>::type, random_access_traversal_tag>::value));
|
||||
//
|
||||
// BOOST_STATIC_ASSERT(is_readable<i0>::value);
|
||||
// BOOST_STATIC_ASSERT(is_writable<i0>::value);
|
||||
// BOOST_STATIC_ASSERT(is_readable<i2>::value);
|
||||
// BOOST_STATIC_ASSERT(!is_writable<i2>::value);
|
||||
|
||||
BOOST_STATIC_ASSERT((is_same<meta::deref<i0>::type, int&>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<meta::deref<i1>::type, char&>::value));
|
||||
|
||||
// BOOST_STATIC_ASSERT((is_same<result_of_get_pointer<i0>::type, int*>::value));
|
||||
// BOOST_STATIC_ASSERT((is_same<result_of_get_pointer<i1>::type, char*>::value));
|
||||
//
|
||||
// BOOST_STATIC_ASSERT((is_same<value_of<i0>::type, int>::value));
|
||||
// BOOST_STATIC_ASSERT((is_same<value_of<i1>::type, char&>::value));
|
||||
//
|
||||
// BOOST_STATIC_ASSERT((is_same<reference_of<i0>::type, int&>::value));
|
||||
// BOOST_STATIC_ASSERT((is_same<reference_of<i1>::type, char&>::value));
|
||||
//
|
||||
// BOOST_STATIC_ASSERT((is_same<pointer_of<i0>::type, int*>::value));
|
||||
// BOOST_STATIC_ASSERT((is_same<pointer_of<i1>::type, char*>::value));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 1999-2003 Jaakko Järvi
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
// 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;
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int, float, bool, foo> t1(5, 12.2f, true, foo(4));
|
||||
get<0>(t1) = 6;
|
||||
get<1>(t1) = 2.2f;
|
||||
get<2>(t1) = false;
|
||||
get<3>(t1) = foo(5);
|
||||
|
||||
BOOST_TEST(get<0>(t1) == 6);
|
||||
BOOST_TEST(get<1>(t1) > 2.1f && get<1>(t1) < 2.3f);
|
||||
BOOST_TEST(get<2>(t1) == false);
|
||||
BOOST_TEST(get<3>(t1) == foo(5));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/mpl/vector_c.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/io.hpp>
|
||||
#include <boost/spirit/fusion/sequence/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/sequence/type_sequence.hpp>
|
||||
#include <boost/spirit/fusion/sequence/generate.hpp>
|
||||
#include <boost/spirit/fusion/sequence/make_tuple.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
operator char const*() const
|
||||
{
|
||||
return "<X-object>";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
using boost::mpl::vector_c;
|
||||
using boost::mpl::int_;
|
||||
using boost::mpl::list;
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
std::cout << tuple_open('[');
|
||||
std::cout << tuple_close(']');
|
||||
std::cout << tuple_delimiter(", ");
|
||||
|
||||
/// Testing type_sequence
|
||||
|
||||
{
|
||||
typedef list<int, double, X> mpl_list1;
|
||||
typedef mpl::begin<mpl_list1>::type begin_type;
|
||||
typedef mpl::end<mpl_list1>::type end_type;
|
||||
typedef tuple<int, double, X> tuple_type;
|
||||
|
||||
type_sequence_iterator<begin_type> iter;
|
||||
tuple_type t1(iter);
|
||||
std::cout << t1 << std::endl;
|
||||
|
||||
BOOST_TEST(t1 == tuple_type());
|
||||
}
|
||||
|
||||
{
|
||||
typedef list<int, double, X, int> mpl_list1;
|
||||
type_sequence<mpl_list1> view;
|
||||
std::cout << generate(view) << std::endl;
|
||||
|
||||
BOOST_TEST((generate(view) == tuple<int, double, X, int>()));
|
||||
}
|
||||
|
||||
{ // MPL constant integer vector
|
||||
|
||||
typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
type_sequence<mpl_vec> view;
|
||||
std::cout << generate(view) << std::endl;
|
||||
|
||||
BOOST_TEST((generate(view) ==
|
||||
tuple<
|
||||
int_<1>
|
||||
, int_<2>
|
||||
, int_<3>
|
||||
, int_<4>
|
||||
, int_<5> >()));
|
||||
}
|
||||
|
||||
#ifdef FUSION_COMFORMING_COMPILER
|
||||
|
||||
{ // Direct MPL sequence operations
|
||||
|
||||
typedef vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
|
||||
std::cout << generate(mpl_vec()) << std::endl;
|
||||
|
||||
tuple<
|
||||
int_<1>
|
||||
, int_<2>
|
||||
, int_<3>
|
||||
, int_<4>
|
||||
, int_<5> >
|
||||
expected;
|
||||
|
||||
BOOST_TEST((generate(mpl_vec()) == expected));
|
||||
BOOST_TEST((mpl_vec() == expected));
|
||||
BOOST_TEST((expected == mpl_vec()));
|
||||
|
||||
boost::fusion::begin(mpl_vec()); // compile check only
|
||||
boost::fusion::end(mpl_vec()); // compile check only
|
||||
|
||||
{ // Testing a VC7.1 bug (see note on deref.hpp)
|
||||
|
||||
typedef vector_c<int, 1, 2, 3> v1_type;
|
||||
v1_type v1;
|
||||
int i = *boost::fusion::begin(v1);
|
||||
(void)i;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple.hpp>
|
||||
#include <boost/spirit/fusion/sequence/get.hpp>
|
||||
|
||||
struct nontrivial
|
||||
{
|
||||
~nontrivial() {}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
|
||||
tuple<int, char> t1(4, 'a');
|
||||
get<1>(t1);
|
||||
|
||||
nontrivial nt;
|
||||
tuple<nontrivial> t3(nt);
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_ANY_HPP)
|
||||
#define FUSION_ALGORITHM_ANY_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/detail/any.ipp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct any
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct any
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct apply
|
||||
{
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline bool
|
||||
operator()(Sequence const& seq, F const& f) const
|
||||
{
|
||||
return detail::any(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, meta::equal_to<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline bool
|
||||
operator()(Sequence& seq, F const& f) const
|
||||
{
|
||||
return detail::any(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, meta::equal_to<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::any const any = function::any();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_DETAIL_ANY_IPP)
|
||||
#define FUSION_ALGORITHM_DETAIL_ANY_IPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
any(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline bool
|
||||
any(First const& first, Last const& last, F const& f, mpl::false_)
|
||||
{
|
||||
if(f(*first))
|
||||
return true;
|
||||
return detail::any(fusion::next(first), last, f
|
||||
, meta::equal_to<BOOST_DEDUCED_TYPENAME meta::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_DETAIL_FIND_IF_HPP)
|
||||
#define FUSION_ALGORITHM_DETAIL_FIND_IF_HPP
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/lambda.hpp>
|
||||
#include <boost/spirit/fusion/iterator/value_of.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename Iterator, typename Pred>
|
||||
struct apply_filter
|
||||
{
|
||||
typedef typename
|
||||
mpl::apply1<
|
||||
Pred
|
||||
, typename meta::value_of<Iterator>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct main_find_if;
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct recursive_find_if
|
||||
{
|
||||
typedef typename
|
||||
main_find_if<
|
||||
typename meta::next<First>::type, Last, Pred
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct main_find_if
|
||||
{
|
||||
typedef mpl::or_<
|
||||
meta::equal_to<First, Last>
|
||||
, apply_filter<First, Pred> >
|
||||
filter;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
filter
|
||||
, mpl::identity<First>
|
||||
, recursive_find_if<First, Last, Pred>
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct static_find_if;
|
||||
|
||||
namespace static_find_if_detail {
|
||||
template <typename First,typename Last,typename Pred,typename Iterator>
|
||||
typename main_find_if<First,Last,typename mpl::lambda<Pred>::type>::type
|
||||
call(static_find_if<First,Last,Pred> const& obj,Iterator const& iter);
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct static_find_if
|
||||
{
|
||||
typedef typename
|
||||
main_find_if<
|
||||
First
|
||||
, Last
|
||||
, typename mpl::lambda<Pred>::type
|
||||
>::type
|
||||
type;
|
||||
|
||||
//Workaround to please MSVC
|
||||
template<typename Iterator>
|
||||
static type
|
||||
call(Iterator const& iter)
|
||||
{
|
||||
return static_find_if_detail::call(static_find_if<First,Last,Pred>(),iter);
|
||||
}
|
||||
};
|
||||
|
||||
namespace static_find_if_detail {
|
||||
template <typename First,typename Last,typename Pred,typename Iterator>
|
||||
typename static_find_if<First,Last,Pred>::type
|
||||
call(static_find_if<First,Last,Pred> const&, Iterator const& iter, mpl::true_)
|
||||
{
|
||||
return iter;
|
||||
};
|
||||
|
||||
template <typename First,typename Last,typename Pred,typename Iterator>
|
||||
typename static_find_if<First,Last,Pred>::type
|
||||
call(static_find_if<First,Last,Pred> const& obj,Iterator const& iter, mpl::false_)
|
||||
{
|
||||
return call(obj,fusion::next(iter));
|
||||
};
|
||||
|
||||
template <typename First,typename Last,typename Pred,typename Iterator>
|
||||
typename main_find_if<First,Last,typename mpl::lambda<Pred>::type>::type
|
||||
call(static_find_if<First,Last,Pred> const& obj,Iterator const& iter)
|
||||
{
|
||||
typedef meta::equal_to<Iterator, BOOST_DEDUCED_TYPENAME static_find_if<First,Last,Pred>::type> found;
|
||||
return call(obj,iter, found());
|
||||
};
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_DETAIL_FOLD_IPP)
|
||||
#define FUSION_ALGORITHM_DETAIL_FOLD_IPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/iterator/value_of.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename Iterator, typename State, typename F>
|
||||
struct fold_apply
|
||||
{
|
||||
typedef typename fusion_apply2<F,
|
||||
typename meta::value_of<Iterator>::type, State
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct static_fold;
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct next_result_of_fold
|
||||
{
|
||||
typedef typename
|
||||
static_fold<
|
||||
typename meta::next<First>::type
|
||||
, Last
|
||||
, typename fold_apply<First, State, F>::type
|
||||
, F
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
struct static_fold
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_same<First, Last>
|
||||
, mpl::identity<State>
|
||||
, next_result_of_fold<First, Last, State, F>
|
||||
>::type
|
||||
result;
|
||||
|
||||
typedef typename result::type type;
|
||||
};
|
||||
|
||||
// terminal case
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
inline State const&
|
||||
fold(First const&, Last const&, State const& state, F const&, mpl::true_)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
// non-terminal case
|
||||
template <typename First, typename Last, typename State, typename F>
|
||||
inline typename static_fold<First, Last, State, F>::type
|
||||
fold(
|
||||
First const& first
|
||||
, Last const& last
|
||||
, State const& state
|
||||
, F const& f
|
||||
, mpl::false_)
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::next(first)
|
||||
, last
|
||||
, f(*first, state)
|
||||
, f
|
||||
, is_same<BOOST_DEDUCED_TYPENAME meta::next<First>::type, Last>()
|
||||
);
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_DETAIL_FOR_EACH_IPP)
|
||||
#define FUSION_ALGORITHM_DETAIL_FOR_EACH_IPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename First, typename Last, typename F>
|
||||
inline void
|
||||
for_each(First const&, Last const&, F const&, mpl::true_)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename First, typename Last, typename F>
|
||||
inline void
|
||||
for_each(First const& first, Last const& last, F const& f, mpl::false_)
|
||||
{
|
||||
f(*first);
|
||||
detail::for_each(fusion::next(first), last, f
|
||||
, meta::equal_to<BOOST_DEDUCED_TYPENAME meta::next<First>::type, Last>());
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_ERASE_HPP)
|
||||
#define FUSION_ALGORITHM_ERASE_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/single_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/joint_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/range.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Position>
|
||||
struct erase
|
||||
{
|
||||
typedef typename meta::begin<Sequence>::type first_type;
|
||||
typedef typename meta::end<Sequence>::type last_type;
|
||||
#if! BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
BOOST_STATIC_ASSERT((!meta::equal_to<Position, last_type>::value));
|
||||
#endif
|
||||
|
||||
typedef typename meta::next<Position>::type next_type;
|
||||
typedef range<first_type, Position> left_type;
|
||||
typedef range<next_type, last_type> right_type;
|
||||
typedef joint_view<left_type, right_type> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct erase
|
||||
{
|
||||
template <typename Sequence, typename Position>
|
||||
struct apply : meta::erase<Sequence, Position> {};
|
||||
|
||||
template <typename Sequence, typename Position>
|
||||
typename apply<Sequence const, Position>::type
|
||||
operator()(Sequence const& seq, Position const& pos) const
|
||||
{
|
||||
typedef apply<Sequence const, Position> meta_type;
|
||||
typedef typename meta_type::left_type left_type;
|
||||
typedef typename meta_type::right_type right_type;
|
||||
typedef typename meta_type::type result_type;
|
||||
|
||||
left_type left(fusion::begin(seq), pos);
|
||||
right_type right(fusion::next(pos), fusion::end(seq));
|
||||
return result_type(left, right);
|
||||
}
|
||||
|
||||
// template <typename Sequence, typename Position>
|
||||
// typename apply<Sequence, Position>::type
|
||||
// operator()(Sequence& seq, Position const& pos) const
|
||||
// {
|
||||
// typedef apply<Sequence, Position> meta;
|
||||
// typedef typename meta::left_type left_type;
|
||||
// typedef typename meta::right_type right_type;
|
||||
// typedef typename meta::type result_type;
|
||||
//
|
||||
// left_type left(fusion::begin(seq), pos);
|
||||
// right_type right(fusion::next(pos), fusion::end(seq));
|
||||
// return result_type(left, right);
|
||||
// }
|
||||
};
|
||||
}
|
||||
|
||||
function::erase const erase = function::erase();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_FILTER_HPP)
|
||||
#define FUSION_ALGORITHM_FILTER_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/filter_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct filter
|
||||
{
|
||||
typedef filter_view<Sequence, Pred> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct filter
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct apply : meta::filter<Sequence, Pred> {};
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
typename apply<Sequence const, Pred>::type
|
||||
operator()(Sequence const& seq, Pred) const
|
||||
{
|
||||
return filter_view<Sequence const, Pred>(seq);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
typename apply<Sequence, Pred>::type
|
||||
operator()(Sequence& seq, Pred) const
|
||||
{
|
||||
return filter_view<Sequence, Pred>(seq);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::filter const filter = function::filter();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_FIND_HPP)
|
||||
#define FUSION_ALGORITHM_FIND_HPP
|
||||
|
||||
#include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct find
|
||||
{
|
||||
typedef typename
|
||||
detail::static_find_if<
|
||||
typename meta::begin<Sequence>::type
|
||||
, typename meta::end<Sequence>::type
|
||||
, is_same<mpl::_, T>
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct find
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct apply : meta::find<Sequence, T> {};
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
typename apply<Sequence const, typename T::type>::type
|
||||
operator()(Sequence const& seq, T) const
|
||||
{
|
||||
typedef
|
||||
detail::static_find_if<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence const>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence const>::type
|
||||
, is_same<mpl::_, BOOST_DEDUCED_TYPENAME T::type>
|
||||
>
|
||||
filter;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
typename apply<Sequence, typename T::type>::type
|
||||
operator()(Sequence& seq, T) const
|
||||
{
|
||||
typedef
|
||||
detail::static_find_if<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type
|
||||
, is_same<mpl::_, BOOST_DEDUCED_TYPENAME T::type>
|
||||
>
|
||||
filter;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::find const find = function::find();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_FIND_IF_HPP)
|
||||
#define FUSION_ALGORITHM_FIND_IF_HPP
|
||||
|
||||
#include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct find_if
|
||||
{
|
||||
typedef typename
|
||||
detail::static_find_if<
|
||||
typename meta::begin<Sequence>::type
|
||||
, typename meta::end<Sequence>::type
|
||||
, Pred
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct find_if
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct apply : meta::find_if<Sequence, Pred> {};
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
inline typename apply<Sequence const, Pred>::type
|
||||
operator()(Sequence const& seq, Pred) const
|
||||
{
|
||||
typedef
|
||||
detail::static_find_if<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence const>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence const>::type
|
||||
, Pred
|
||||
>
|
||||
filter;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
inline typename apply<Sequence, Pred>::type
|
||||
operator()(Sequence& seq, Pred) const
|
||||
{
|
||||
typedef
|
||||
detail::static_find_if<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type
|
||||
, Pred
|
||||
>
|
||||
filter;
|
||||
|
||||
return filter::call(fusion::begin(seq));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::find_if const find_if = function::find_if();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_FOLD_HPP)
|
||||
#define FUSION_ALGORITHM_FOLD_HPP
|
||||
|
||||
#include <boost/spirit/fusion/algorithm/detail/fold.ipp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename State, typename F>
|
||||
struct fold
|
||||
{
|
||||
typedef typename
|
||||
detail::static_fold<
|
||||
typename meta::begin<Sequence>::type
|
||||
, typename meta::end<Sequence>::type
|
||||
, State
|
||||
, F
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct fold
|
||||
{
|
||||
template <typename Sequence, typename State, typename F>
|
||||
struct apply : meta::fold<Sequence, State, F> {};
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename apply<Sequence const, State, F>::type
|
||||
operator()(Sequence const& seq, State const& state, F const& f) const
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence const>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence const>::type>()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename State, typename F>
|
||||
inline typename apply<Sequence, State, F>::type
|
||||
operator()(Sequence& seq, State const& state, F const& f) const
|
||||
{
|
||||
return detail::fold(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, state
|
||||
, f
|
||||
, is_same<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>()
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::fold const fold = function::fold();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_FOR_EACH_HPP)
|
||||
#define FUSION_ALGORITHM_FOR_EACH_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/detail/for_each.ipp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct for_each
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct for_each
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct apply
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline void
|
||||
operator()(Sequence const& seq, F const& f) const
|
||||
{
|
||||
detail::for_each(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, meta::equal_to<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
inline void
|
||||
operator()(Sequence& seq, F const& f) const
|
||||
{
|
||||
detail::for_each(
|
||||
fusion::begin(seq)
|
||||
, fusion::end(seq)
|
||||
, f
|
||||
, meta::equal_to<
|
||||
BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
|
||||
, BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::for_each const for_each = function::for_each();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_INSERT_HPP)
|
||||
#define FUSION_ALGORITHM_INSERT_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/single_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/joint_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/range.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
struct insert
|
||||
{
|
||||
typedef typename meta::begin<Sequence>::type first_type;
|
||||
typedef typename meta::end<Sequence>::type last_type;
|
||||
|
||||
typedef const single_view<T> insert_type;
|
||||
typedef range<first_type, Position> left_type;
|
||||
typedef range<Position, last_type> right_type;
|
||||
typedef joint_view<left_type, insert_type, true, true> left_insert_type;
|
||||
typedef joint_view<left_insert_type, right_type, true, true> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct insert
|
||||
{
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
struct apply : meta::insert<Sequence, Position, T> {};
|
||||
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
inline typename apply<Sequence const, Position, T>::type
|
||||
operator()(Sequence const& seq, Position const& pos, T const& x) const
|
||||
{
|
||||
typedef apply<Sequence const, Position, T> meta;
|
||||
typedef typename meta::left_type left_type;
|
||||
typedef typename meta::right_type right_type;
|
||||
typedef typename meta::left_insert_type left_insert_type;
|
||||
typedef typename meta::insert_type insert_type;
|
||||
typedef typename meta::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), pos);
|
||||
right_type right(pos, fusion::end(seq));
|
||||
insert_type ins(x);
|
||||
left_insert_type left_insert(left, ins);
|
||||
return result(left_insert, right);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
inline typename apply<Sequence, Position, T>::type
|
||||
operator()(Sequence& seq, Position const& pos, T const& x) const
|
||||
{
|
||||
typedef apply<Sequence, Position, T> meta_type;
|
||||
typedef typename meta_type::left_type left_type;
|
||||
typedef typename meta_type::right_type right_type;
|
||||
typedef typename meta_type::left_insert_type left_insert_type;
|
||||
typedef typename meta_type::insert_type insert_type;
|
||||
typedef typename meta_type::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), pos);
|
||||
right_type right(pos, fusion::end(seq));
|
||||
insert_type ins(x);
|
||||
left_insert_type left_insert(left, ins);
|
||||
return result(left_insert, right);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::insert const insert = function::insert();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_PUSH_BACK_HPP)
|
||||
#define FUSION_ALGORITHM_PUSH_BACK_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/append_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct push_back
|
||||
{
|
||||
typedef append_view<Sequence, T> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct push_back
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct apply : meta::push_back<Sequence, T> {};
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename apply<Sequence const, T>::type
|
||||
operator()(Sequence const& seq, T const& x) const
|
||||
{
|
||||
typedef append_view<Sequence const, T> result;
|
||||
return result(seq, x);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename apply<Sequence, T>::type
|
||||
operator()(Sequence& seq, T const& x) const
|
||||
{
|
||||
typedef append_view<Sequence, T> result;
|
||||
return result(seq, x);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::push_back const push_back = function::push_back();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_PUSH_FRONT_HPP)
|
||||
#define FUSION_ALGORITHM_PUSH_FRONT_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/prepend_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct push_front
|
||||
{
|
||||
typedef prepend_view<Sequence, T> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct push_front
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct apply : meta::push_front<Sequence, T> {};
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename apply<Sequence const, T>::type
|
||||
operator()(Sequence const& seq, T const& x) const
|
||||
{
|
||||
typedef prepend_view<Sequence const, T> result;
|
||||
return result(seq, x);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline typename apply<Sequence, T>::type
|
||||
operator()(Sequence& seq, T const& x) const
|
||||
{
|
||||
typedef prepend_view<Sequence, T> result;
|
||||
return result(seq, x);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::push_front const push_front = function::push_front();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_REMOVE_HPP)
|
||||
#define FUSION_ALGORITHM_REMOVE_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/filter_view.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct remove
|
||||
{
|
||||
typedef filter_view<Sequence, mpl::not_<is_same<mpl::_, T> > > type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct remove
|
||||
{
|
||||
template <typename Sequence, typename T>
|
||||
struct apply : meta::remove<Sequence, T> {};
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline filter_view<
|
||||
Sequence const
|
||||
, mpl::not_<is_same<mpl::_, typename T::type> > >
|
||||
operator()(Sequence const& seq, T) const
|
||||
{
|
||||
return filter_view<
|
||||
Sequence const
|
||||
, mpl::not_<is_same<mpl::_, BOOST_DEDUCED_TYPENAME T::type>
|
||||
> >(seq);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename T>
|
||||
inline filter_view<
|
||||
Sequence
|
||||
, mpl::not_<is_same<mpl::_, typename T::type> > >
|
||||
operator()(Sequence& seq, T) const
|
||||
{
|
||||
return filter_view<
|
||||
Sequence
|
||||
, mpl::not_<is_same<mpl::_, BOOST_DEDUCED_TYPENAME T::type>
|
||||
> >(seq);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::remove const remove = function::remove();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_REMOVE_IF_HPP)
|
||||
#define FUSION_ALGORITHM_REMOVE_IF_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/filter_view.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct remove_if
|
||||
{
|
||||
typedef filter_view<Sequence, mpl::not_<Pred> > type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct remove_if
|
||||
{
|
||||
template <typename Sequence, typename Pred>
|
||||
struct apply : meta::remove_if<Sequence, Pred> {};
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
inline typename apply<Sequence const, Pred>::type
|
||||
operator()(Sequence const& seq, Pred) const
|
||||
{
|
||||
return filter_view<Sequence const, mpl::not_<Pred> >(seq);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Pred>
|
||||
inline typename apply<Sequence, Pred>::type
|
||||
operator()(Sequence& seq, Pred) const
|
||||
{
|
||||
return filter_view<Sequence, mpl::not_<Pred> >(seq);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::remove_if const remove_if = function::remove_if();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_REPLACE_HPP)
|
||||
#define FUSION_ALGORITHM_REPLACE_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/single_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/joint_view.hpp>
|
||||
#include <boost/spirit/fusion/sequence/range.hpp>
|
||||
#include <boost/spirit/fusion/sequence/begin.hpp>
|
||||
#include <boost/spirit/fusion/sequence/end.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
struct replace
|
||||
{
|
||||
typedef typename meta::begin<Sequence>::type first_type;
|
||||
typedef typename meta::end<Sequence>::type last_type;
|
||||
typedef typename meta::next<Position>::type next_type;
|
||||
#if! BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
BOOST_STATIC_ASSERT((!meta::equal_to<Position, last_type>::value));
|
||||
#endif
|
||||
typedef const single_view<T> insert_type;
|
||||
typedef range<first_type, Position> left_type;
|
||||
typedef range<next_type, last_type> right_type;
|
||||
typedef joint_view<left_type, insert_type, true, true> left_replace_type;
|
||||
typedef joint_view<left_replace_type, right_type, true, true> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct replace
|
||||
{
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
struct apply : meta::replace<Sequence, Position, T> {};
|
||||
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
typename apply<Sequence const, Position, T>::type
|
||||
operator()(Sequence const& seq, Position const& pos, T const& x) const
|
||||
{
|
||||
typedef apply<Sequence const, Position, T> replacer;
|
||||
|
||||
typedef typename replacer::left_type left_type;
|
||||
typedef typename replacer::right_type right_type;
|
||||
typedef typename replacer::left_replace_type left_replace_type;
|
||||
typedef typename replacer::insert_type insert_type;
|
||||
typedef typename replacer::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), pos);
|
||||
right_type right(fusion::next(pos), fusion::end(seq));
|
||||
insert_type ins(x);
|
||||
left_replace_type left_replace(left, ins);
|
||||
return result(left_replace, right);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename Position, typename T>
|
||||
typename apply<Sequence, Position, T>::type
|
||||
operator()(Sequence& seq, Position const& pos, T const& x) const
|
||||
{
|
||||
typedef apply<Sequence, Position, T> replacer;
|
||||
|
||||
typedef typename replacer::left_type left_type;
|
||||
typedef typename replacer::right_type right_type;
|
||||
typedef typename replacer::left_replace_type left_replace_type;
|
||||
typedef typename replacer::insert_type insert_type;
|
||||
typedef typename replacer::type result;
|
||||
|
||||
left_type left(fusion::begin(seq), pos);
|
||||
right_type right(fusion::next(pos), fusion::end(seq));
|
||||
insert_type ins(x);
|
||||
left_replace_type left_replace(left, ins);
|
||||
return result(left_replace, right);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::replace const replace = function::replace();
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ALGORITHM_TRANSFORM_HPP)
|
||||
#define FUSION_ALGORITHM_TRANSFORM_HPP
|
||||
|
||||
#include <boost/spirit/fusion/sequence/transform_view.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct transform
|
||||
{
|
||||
typedef transform_view<Sequence, F> type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace function
|
||||
{
|
||||
struct transform
|
||||
{
|
||||
template <typename Sequence, typename F>
|
||||
struct apply : meta::transform<Sequence, F> {};
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
typename apply<Sequence const, F>::type
|
||||
operator()(Sequence const& seq, F const& f) const
|
||||
{
|
||||
return transform_view<Sequence const, F>(seq, f);
|
||||
}
|
||||
|
||||
template <typename Sequence, typename F>
|
||||
typename apply<Sequence, F>::type
|
||||
operator()(Sequence& seq, F const& f) const
|
||||
{
|
||||
return transform_view<Sequence, F>(seq, f);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function::transform const transform = function::transform();
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_DETAIL_ACCESS_HPP)
|
||||
#define FUSION_DETAIL_ACCESS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct ref_result
|
||||
{
|
||||
typedef typename add_reference<FUSION_GET_TYPE(T)>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct cref_result
|
||||
{
|
||||
typedef typename add_reference<
|
||||
typename add_const<FUSION_GET_TYPE(T)>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct non_ref_parameter
|
||||
{
|
||||
typedef typename boost::remove_cv<T>::type const& type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct call_param
|
||||
{
|
||||
typedef
|
||||
typename mpl::eval_if<
|
||||
is_reference<T>
|
||||
, mpl::identity<T>
|
||||
, non_ref_parameter<T>
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,442 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_DETAIL_CONFIG_HPP)
|
||||
#define FUSION_DETAIL_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#endif
|
||||
|
||||
#if (defined(BOOST_MSVC) && (BOOST_MSVC < 1310)) \
|
||||
|| (defined(__BORLANDC__) && (__BORLANDC__ <= 0x570)) \
|
||||
|| (defined(__GNUC__) && (__GNUC__ < 3)) \
|
||||
|| (defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
|
||||
#else
|
||||
# define FUSION_COMFORMING_COMPILER
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BOOST_NO_TEMPLATED_STREAMS macro. This ought to be in boost.config
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ <= 97
|
||||
#define BOOST_NO_TEMPLATED_STREAMS
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Before including MPL, we define these dummy template functions. Borland
|
||||
// complains when a template class has the same name as a template function,
|
||||
// regardless if they are in different namespaces. This is a workaround to
|
||||
// this Borland quirk.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
|
||||
namespace boost { namespace fusion { namespace borland_only {
|
||||
|
||||
template <typename T> void begin(T) {}
|
||||
template <typename T> void end(T) {}
|
||||
template <typename T> void next(T) {}
|
||||
template <typename T> void prior(T) {}
|
||||
template <typename T> void find(T) {}
|
||||
template <typename T> void find_if(T) {}
|
||||
|
||||
}}}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MSVC, even with VC7.1 has problems with returning a default constructed
|
||||
// value of a given type: return type(); This only happens on debug builds.
|
||||
// It seems to be a return value optimization bug.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1301) && !defined(NDEBUG)
|
||||
# define FUSION_RETURN_DEFAULT_CONSTRUCTED type r=type(); return r
|
||||
#else
|
||||
# define FUSION_RETURN_DEFAULT_CONSTRUCTED return type()
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Borland does not like the T::value syntax. Instead, we use a metafunction
|
||||
// get_value<T>::value. The explicit qualification (::boost::fusion::detail::)
|
||||
// also makes Borland happy.
|
||||
//
|
||||
// VC6/7 on the other hand chokes with ETI (early instantiation bug). So we
|
||||
// forward the call to get_value<T>::value and fix the ETI bug there (see
|
||||
// get_value below).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) \
|
||||
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct get_value
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value = T::value);
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
// VC6 ETI (early template instantiation) bug workaround.
|
||||
template <>
|
||||
struct get_value<int>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
#endif
|
||||
}}}
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551) \
|
||||
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# define FUSION_GET_VALUE(T) ::boost::fusion::detail::get_value<T>::value
|
||||
#else
|
||||
# define FUSION_GET_VALUE(T) T::value
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Borland does not like returning a const reference from a tuple member.
|
||||
// We do the cast explicitly.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
|
||||
# define FUSION_RETURN_TUPLE_MEMBER(n) \
|
||||
typedef typename tuple_access_result<n, Tuple>::type type; \
|
||||
return type(t.BOOST_PP_CAT(m, n))
|
||||
#else
|
||||
# define FUSION_RETURN_TUPLE_MEMBER(n) \
|
||||
return t.BOOST_PP_CAT(m, n)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See get.hpp. In function get<N>(t), mpl::int_<N>* = 0 is a function
|
||||
// parameter that defaults to 0. This is a hack to make VC6 happy, otherwise,
|
||||
// VC6 will return the wrong result from a wrong index!
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
# define FUSION_GET_MSVC_WORKAROUND , mpl::int_<N>* = 0
|
||||
#else
|
||||
# define FUSION_GET_MSVC_WORKAROUND
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUSION_MSVC_ETI_WRAPPER (VC6 and VC7)
|
||||
//
|
||||
// VC6/VC7 chokes with ETI (early instantiation bug) with typename T::name.
|
||||
// So, we forward the call to get_name<T>::type and fix the ETI bug.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// VC6 ETI (early template instantiation) bug workaround.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
#define FUSION_MSVC_ETI_WRAPPER(name) \
|
||||
namespace boost { namespace fusion { namespace detail \
|
||||
{ \
|
||||
template <typename T> \
|
||||
struct BOOST_PP_CAT(get_, name) \
|
||||
{ \
|
||||
typedef typename T::name type; \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct BOOST_PP_CAT(get_, name)<int> \
|
||||
{ \
|
||||
typedef int type; \
|
||||
}; \
|
||||
}}}
|
||||
#endif
|
||||
/*
|
||||
// is_msvc_70_ETI_arg: Detect a VC7 ETI arg
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
struct int_convertible_
|
||||
{
|
||||
int_convertible_(int);
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct is_msvc_70_ETI_arg
|
||||
{
|
||||
typedef char (&no_tag)[1];
|
||||
typedef char (&yes_tag)[2];
|
||||
|
||||
static no_tag test(...);
|
||||
static yes_tag test(int_convertible_);
|
||||
static T get();
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
sizeof(test(get())) == sizeof(yes_tag)
|
||||
);
|
||||
};
|
||||
}}}
|
||||
#endif
|
||||
|
||||
// VC7 ETI (early template instantiation) bug workaround.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
#define FUSION_MSVC_ETI_WRAPPER(name) \
|
||||
namespace boost { namespace fusion { namespace detail \
|
||||
{ \
|
||||
template <bool> \
|
||||
struct BOOST_PP_CAT(get_impl_, name) \
|
||||
{ \
|
||||
template <typename T> \
|
||||
struct result \
|
||||
{ \
|
||||
typedef int type; \
|
||||
}; \
|
||||
}; \
|
||||
\
|
||||
struct BOOST_PP_CAT(get_impl_, name)<false> \
|
||||
{ \
|
||||
template <typename T> \
|
||||
struct result \
|
||||
{ \
|
||||
typedef typename T::name type; \
|
||||
}; \
|
||||
}; \
|
||||
\
|
||||
template <typename T> \
|
||||
struct BOOST_PP_CAT(get_, name) \
|
||||
: BOOST_PP_CAT(get_impl_, name)<is_msvc_70_ETI_arg<T>::value> \
|
||||
::template result<T> {}; \
|
||||
}}}
|
||||
#endif
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::tag wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(tag)
|
||||
# define FUSION_GET_TAG(T) ::boost::fusion::detail::get_tag<T>::type
|
||||
#else
|
||||
# define FUSION_GET_TAG(T) typename T::tag
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::type wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(type)
|
||||
# define FUSION_GET_TYPE(T) ::boost::fusion::detail::get_type<T>::type
|
||||
#else
|
||||
# define FUSION_GET_TYPE(T) typename T::type
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::types wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(types)
|
||||
# define FUSION_GET_TYPES(T) ::boost::fusion::detail::get_types<T>::type
|
||||
#else
|
||||
# define FUSION_GET_TYPES(T) typename T::types
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::index wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(index)
|
||||
# define FUSION_GET_INDEX(T) ::boost::fusion::detail::get_index<T>::type
|
||||
#else
|
||||
# define FUSION_GET_INDEX(T) typename T::index
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::tuple wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(tuple)
|
||||
# define FUSION_GET_TUPLE(T) ::boost::fusion::detail::get_tuple<T>::type
|
||||
#else
|
||||
# define FUSION_GET_TUPLE(T) typename T::tuple
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::size wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(size)
|
||||
# define FUSION_GET_SIZE(T) ::boost::fusion::detail::get_size<T>::type
|
||||
#else
|
||||
# define FUSION_GET_SIZE(T) typename T::size
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// T::value_type wrapper
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
FUSION_MSVC_ETI_WRAPPER(value_type)
|
||||
# define FUSION_GET_VALUE_TYPE(T) ::boost::fusion::detail::get_value_type<T>::type
|
||||
#else
|
||||
# define FUSION_GET_VALUE_TYPE(T) typename T::value_type
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
namespace boost {namespace fusion { namespace aux {
|
||||
template< typename T >
|
||||
struct msvc_never_true
|
||||
{
|
||||
enum { value = false };
|
||||
};
|
||||
}}} //namespace boost::fusion::aux
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {namespace fusion {
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
namespace aux {
|
||||
// msvc_apply
|
||||
#define AUX778076_MSVC_DTW_NAME msvc_apply1
|
||||
#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
|
||||
#define AUX778076_MSVC_DTW_ARITY 1
|
||||
#include "boost/mpl/aux_/msvc_dtw.hpp"
|
||||
|
||||
#define AUX778076_MSVC_DTW_NAME msvc_apply2
|
||||
#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
|
||||
#define AUX778076_MSVC_DTW_ARITY 2
|
||||
#include "boost/mpl/aux_/msvc_dtw.hpp"
|
||||
|
||||
} //namespace aux
|
||||
|
||||
template<typename A,typename B>
|
||||
struct fusion_apply1
|
||||
{
|
||||
typedef typename aux::msvc_apply1<A>::template result_<B>::type type;
|
||||
};
|
||||
|
||||
template<typename A,typename B,typename C>
|
||||
struct fusion_apply2
|
||||
{
|
||||
typedef typename aux::msvc_apply2<A>::template result_<B,C>::type type;
|
||||
};
|
||||
|
||||
#else
|
||||
template<typename A,typename B>
|
||||
struct fusion_apply1
|
||||
{
|
||||
typedef typename A::template apply<B>::type type;
|
||||
};
|
||||
template<typename A,typename B,typename C>
|
||||
struct fusion_apply2
|
||||
{
|
||||
typedef typename A::template apply<B,C>::type type;
|
||||
};
|
||||
#endif
|
||||
}} //namespace boost::fusion
|
||||
|
||||
namespace boost {namespace fusion {namespace detail {
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template<typename T>
|
||||
struct bool_base {};
|
||||
template<>
|
||||
struct bool_base<mpl::bool_<true> > : boost::mpl::bool_<true>{};
|
||||
template<>
|
||||
struct bool_base<mpl::bool_<false> > : boost::mpl::bool_<false>{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct bool_base : T {};
|
||||
#endif
|
||||
}}}
|
||||
|
||||
//VC 6 has serious problems with mpl::int_ in tuple_iterator_base.
|
||||
//It ICEs because operator int() const on mpl::int_ is inlined.
|
||||
//At the same time, another test using integral_c<T,N> ICEs because operator int() is not inlined.
|
||||
//Only solution seems to be to define a special msvc_fusion_int for VC 6 to be used in tuple_iterator_base
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
namespace boost {namespace fusion {namespace detail{
|
||||
|
||||
template<int N>
|
||||
struct msvc_fusion_int
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, value = N);
|
||||
typedef msvc_fusion_int<N> type;
|
||||
typedef int value_type;
|
||||
typedef boost::mpl::integral_c_tag tag;
|
||||
|
||||
typedef msvc_fusion_int<value + 1> next;
|
||||
typedef msvc_fusion_int<value - 1> prior;
|
||||
|
||||
operator int() const;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
msvc_fusion_int<N>::operator int() const
|
||||
{
|
||||
return static_cast<int>(this->value);
|
||||
}
|
||||
|
||||
}}}
|
||||
#define FUSION_INT(N) boost::fusion::detail::msvc_fusion_int<N>
|
||||
#else
|
||||
#define FUSION_INT(N) boost::mpl::int_<N>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Borland is so flaky with const correctness of iterators. It's getting
|
||||
// confused with tuple_iterator<N, T> where T is a const tuple. We cast
|
||||
// what Borland thinks is a const reference to a true reference.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
|
||||
|
||||
template <typename T>
|
||||
T& ref(T const& r)
|
||||
{
|
||||
return const_cast<T&>(r);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
T& ref(T& r)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_SEQUENCE_AS_FUSION_ITERATOR_HPP)
|
||||
#define FUSION_SEQUENCE_AS_FUSION_ITERATOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/is_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/type_sequence_iterator.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
// Test T. If it is a fusion iterator, return a reference to it.
|
||||
// else, assume it is an mpl iterator.
|
||||
|
||||
namespace as_fusion_iterator_detail {
|
||||
template <typename T>
|
||||
static T const&
|
||||
convert(T const& x, mpl::true_)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static type_sequence_iterator<T>
|
||||
convert(T const& x, mpl::false_)
|
||||
{
|
||||
return type_sequence_iterator<T>();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct as_fusion_iterator
|
||||
{
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
fusion::is_iterator<T>
|
||||
, T
|
||||
, type_sequence_iterator<T>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static typename
|
||||
mpl::if_<
|
||||
fusion::is_iterator<T>
|
||||
, T const&
|
||||
, type_sequence_iterator<T>
|
||||
>::type
|
||||
convert(T const& x);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
typename
|
||||
mpl::if_<
|
||||
fusion::is_iterator<T>
|
||||
, T const&
|
||||
, type_sequence_iterator<T>
|
||||
>::type
|
||||
as_fusion_iterator<T>::convert(T const& x)
|
||||
{
|
||||
return as_fusion_iterator_detail::convert(x, fusion::is_iterator<T>());
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,81 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_CONS_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_CONS_ITERATOR_HPP
|
||||
|
||||
#include <boost/mpl/aux_/na_fwd.hpp>
|
||||
#include <boost/mpl/iterator_tags.hpp>
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/sequence/detail/sequence_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/cons_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/cons_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/cons_iterator/value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct nil;
|
||||
|
||||
struct cons_iterator_tag;
|
||||
|
||||
template <typename Cons = nil>
|
||||
struct cons_iterator : iterator_base<cons_iterator<Cons> >
|
||||
{
|
||||
typedef cons_iterator_tag tag;
|
||||
typedef Cons cons_type;
|
||||
typedef mpl::forward_iterator_tag category;
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
typedef typename cons_detail::next_traits_impl<cons_iterator>::type next;
|
||||
typedef typename cons_detail::value_traits_impl<cons_iterator>::type type;
|
||||
#endif
|
||||
|
||||
explicit cons_iterator(cons_type& cons_)
|
||||
: cons(cons_) {}
|
||||
|
||||
cons_type& cons;
|
||||
private:
|
||||
cons_iterator& operator=(cons_iterator const&);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct cons_iterator<nil> : iterator_base<cons_iterator<nil> >
|
||||
{
|
||||
typedef cons_iterator_tag tag;
|
||||
typedef nil cons_type;
|
||||
typedef mpl::forward_iterator_tag category;
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
typedef cons_iterator next;
|
||||
typedef mpl::na type;
|
||||
#endif
|
||||
|
||||
cons_iterator() {}
|
||||
explicit cons_iterator(nil const&) {}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct cons_iterator<nil const> : iterator_base<cons_iterator<nil const> >
|
||||
{
|
||||
typedef cons_iterator_tag tag;
|
||||
typedef nil const cons_type;
|
||||
typedef mpl::forward_iterator_tag category;
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
typedef cons_iterator next;
|
||||
typedef mpl::na type;
|
||||
#endif
|
||||
|
||||
cons_iterator() {}
|
||||
explicit cons_iterator(nil const&) {}
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,101 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DEREF_HPP)
|
||||
#define FUSION_ITERATOR_DEREF_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply {};
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct deref
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
typedef typename
|
||||
deref_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace deref_detail {
|
||||
template <typename Iterator>
|
||||
typename meta::deref<Iterator>::type
|
||||
deref(Iterator const& i,mpl::true_)
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
typename meta::deref<iter>::type result =
|
||||
meta::deref_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::call(converter::convert(i));
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename meta::deref<Iterator>::type
|
||||
deref(Iterator& i,mpl::false_)
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
typename meta::deref<iter>::type result =
|
||||
meta::deref_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::call(converter::convert(i));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
typename meta::deref<Iterator>::type
|
||||
deref(Iterator& i) {
|
||||
return deref_detail::deref(i,is_const<Iterator>());
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
typename meta::deref<Iterator>::type
|
||||
deref(Iterator const & i) {
|
||||
return deref_detail::deref(i,is_const<Iterator const>());
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
typename meta::deref<Iterator>::type
|
||||
operator*(iterator_base<Iterator> const& i)
|
||||
{
|
||||
return fusion::deref(i.cast());
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename meta::deref<Iterator>::type
|
||||
operator*(iterator_base<Iterator>& i)
|
||||
{
|
||||
return fusion::deref(i.cast());
|
||||
}
|
||||
|
||||
// Note: VC7.1 has a problem when we pass the return value directly.
|
||||
// Try removing the named temporary. This only happens on debug builds.
|
||||
// It seems to be a return value optimization bug.
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ADAPT_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ADAPT_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
namespace adapt_deref_detail {
|
||||
template<typename Iterator>
|
||||
struct deref_traits_impl
|
||||
{
|
||||
typedef typename
|
||||
meta::deref<typename Iterator::first_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
typename deref_traits_impl<Iterator>::type
|
||||
deref_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return *i.first;
|
||||
}
|
||||
}
|
||||
struct adapt_deref_traits {
|
||||
template<typename Iterator>
|
||||
struct apply : adapt_deref_detail::deref_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ADAPT_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ADAPT_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/value_of.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
struct adapt_value_traits
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
meta::value_of<typename Iterator::first_type>::type
|
||||
type;
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_CONS_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_CONS_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct cons_iterator_tag;
|
||||
|
||||
namespace cons_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct deref_traits_impl
|
||||
{
|
||||
typedef typename Iterator::cons_type cons_type;
|
||||
typedef typename cons_type::car_type value_type;
|
||||
|
||||
typedef typename mpl::eval_if<
|
||||
is_const<cons_type>
|
||||
, add_reference<typename add_const<value_type>::type>
|
||||
, add_reference<value_type> >::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return detail::ref(i.cons.car);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<cons_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : cons_detail::deref_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_CONS_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_CONS_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct cons_iterator_tag;
|
||||
|
||||
template <typename Cons>
|
||||
struct cons_iterator;
|
||||
|
||||
namespace cons_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct next_traits_impl
|
||||
{
|
||||
typedef typename Iterator::cons_type cons_type;
|
||||
typedef typename cons_type::cdr_type cdr_type;
|
||||
|
||||
typedef cons_iterator<
|
||||
typename mpl::eval_if<
|
||||
is_const<cons_type>
|
||||
, add_const<cdr_type>
|
||||
, mpl::identity<cdr_type>
|
||||
>::type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i)
|
||||
{
|
||||
return type(detail::ref(i.cons.cdr));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<cons_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : cons_detail::next_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct next;
|
||||
|
||||
template <typename Cons>
|
||||
struct next<fusion::cons_iterator<Cons> >
|
||||
: fusion::cons_detail::next_traits_impl<fusion::cons_iterator<Cons> >
|
||||
{
|
||||
};
|
||||
}}
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2005 Eric Niebler
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_CONS_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_CONS_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct cons_iterator_tag;
|
||||
|
||||
namespace cons_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct value_traits_impl
|
||||
{
|
||||
typedef typename Iterator::cons_type cons_type;
|
||||
typedef typename cons_type::car_type type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<cons_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : cons_detail::value_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
namespace boost { namespace mpl
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct deref;
|
||||
|
||||
template <typename Cons>
|
||||
struct deref<fusion::cons_iterator<Cons> >
|
||||
: fusion::cons_detail::value_traits_impl<fusion::cons_iterator<Cons> >
|
||||
{
|
||||
};
|
||||
}}
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/adapt_deref_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<filter_view_iterator_tag> : detail::adapt_deref_traits
|
||||
{};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003-2005 Joel de Guzman
|
||||
Copyright (c) 2005 Dan Marsden
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_EQUAL_TO_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_EQUAL_TO_TRAITS_HPP
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template<typename I1, typename I2>
|
||||
struct equal_to;
|
||||
|
||||
template<typename Tag>
|
||||
struct equal_to_impl;
|
||||
|
||||
template<>
|
||||
struct equal_to_impl<filter_view_iterator_tag>
|
||||
{
|
||||
template<typename I1, typename I2>
|
||||
struct apply
|
||||
: equal_to<typename I1::first_type, typename I2::first_type>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_iterator_tag;
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct filter_iterator;
|
||||
|
||||
namespace filter_view_detail {
|
||||
template<typename Iterator>
|
||||
struct next_traits_impl {
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename Iterator::last_type last_type;
|
||||
typedef typename Iterator::pred_type pred_type;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
meta::equal_to<first_type, last_type>
|
||||
, mpl::identity<last_type>
|
||||
, meta::next<first_type>
|
||||
>::type
|
||||
next_type;
|
||||
|
||||
typedef typename detail::static_find_if<
|
||||
next_type, last_type, pred_type>
|
||||
filter;
|
||||
|
||||
typedef filter_iterator<
|
||||
typename filter::type, last_type, pred_type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
template<typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
next_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return type(filter::call(i.first));
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<filter_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : filter_view_detail::next_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_FILTER_VIEW_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/adapt_value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<filter_view_iterator_tag>
|
||||
: detail::adapt_value_traits {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_ITERATOR_BASE_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_ITERATOR_BASE_HPP
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct iterator_root {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct iterator_base : iterator_root
|
||||
{
|
||||
Iterator const&
|
||||
cast() const;
|
||||
|
||||
Iterator&
|
||||
cast();
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
Iterator const&
|
||||
iterator_base<Iterator>::cast() const
|
||||
{
|
||||
return static_cast<Iterator const&>(*this);
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
Iterator&
|
||||
iterator_base<Iterator>::cast()
|
||||
{
|
||||
return static_cast<Iterator&>(*this);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/adapt_deref_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<joint_view_iterator_tag>
|
||||
: detail::adapt_deref_traits {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
template <typename First, typename Last, typename Concat>
|
||||
struct joint_view_iterator;
|
||||
|
||||
namespace join_view_detail {
|
||||
template<typename Iterator>
|
||||
struct next_traits_impl {
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename Iterator::last_type last_type;
|
||||
typedef typename Iterator::concat_type concat_type;
|
||||
typedef typename meta::next<first_type>::type next_type;
|
||||
typedef meta::equal_to<next_type, last_type> equal_to;
|
||||
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
equal_to
|
||||
, concat_type
|
||||
, joint_view_iterator<next_type, last_type, concat_type>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
call(Iterator const& i, mpl::true_)
|
||||
{
|
||||
return i.concat;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
call(Iterator const& i, mpl::false_)
|
||||
{
|
||||
typedef typename next_traits_impl<Iterator>::type type;
|
||||
return type(fusion::next(i.first), i.concat);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
next_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return join_view_detail::call(i, equal_to());
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<joint_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : join_view_detail::next_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/adapt_value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<joint_view_iterator_tag>
|
||||
: detail::adapt_value_traits {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/detail/access.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename SingleView>
|
||||
struct single_view_access_result
|
||||
{
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_const<SingleView>
|
||||
, cref_result<mpl::identity<FUSION_GET_VALUE_TYPE(SingleView)> >
|
||||
, ref_result<mpl::identity<FUSION_GET_VALUE_TYPE(SingleView)> >
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace single_view_iterator_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct deref_traits_impl
|
||||
{
|
||||
typedef typename Iterator::single_view_type single_view_type;
|
||||
typedef typename detail::single_view_access_result<
|
||||
single_view_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename deref_traits_impl<Iterator>::type
|
||||
deref_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return detail::ref(i.view.val);
|
||||
}
|
||||
}
|
||||
|
||||
struct single_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<single_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : single_view_iterator_detail::deref_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct single_view_iterator_tag;
|
||||
|
||||
template <typename SingleView>
|
||||
struct single_view_iterator_end;
|
||||
|
||||
template <typename SingleView>
|
||||
struct single_view_iterator;
|
||||
|
||||
namespace single_view_detail
|
||||
{
|
||||
template<typename Iterator>
|
||||
struct next_traits_impl
|
||||
{
|
||||
typedef single_view_iterator_end<
|
||||
typename Iterator::single_view_type>
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator);
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
next_traits_impl<Iterator>::call(Iterator)
|
||||
{
|
||||
FUSION_RETURN_DEFAULT_CONSTRUCTED;
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<single_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : single_view_detail::next_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_SINGLE_VIEW_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct single_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<single_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Iterator::single_view_type single_view_type;
|
||||
typedef FUSION_GET_VALUE_TYPE(single_view_type) type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/deref.hpp>
|
||||
#include <boost/spirit/fusion/iterator/value_of.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
|
||||
namespace transform_view_detail {
|
||||
template<typename Iterator>
|
||||
struct deref_traits_impl {
|
||||
typedef typename
|
||||
meta::value_of<typename Iterator::first_type>::type
|
||||
value_type;
|
||||
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef typename fusion_apply1<transform_type, value_type>::type type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
BOOST_DEDUCED_TYPENAME deref_traits_impl<Iterator>::type
|
||||
deref_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return i.f(*i.first);
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : transform_view_detail::deref_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
|
||||
template <typename First, typename F>
|
||||
struct transform_view_iterator;
|
||||
|
||||
namespace transform_view_detail {
|
||||
template <typename Iterator>
|
||||
struct next_traits_impl
|
||||
{
|
||||
typedef typename Iterator::first_type first_type;
|
||||
typedef typename meta::next<first_type>::type next_type;
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef transform_view_iterator<next_type, transform_type> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
template <typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
next_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return type(fusion::next(i.first), i.f);
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : transform_view_detail::next_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TRANSFORM_VIEW_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/adapt_value_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/value_of.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<transform_view_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
meta::value_of<typename Iterator::first_type>::type
|
||||
value_type;
|
||||
|
||||
typedef typename Iterator::transform_type transform_type;
|
||||
typedef typename fusion_apply1<transform_type,value_type>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/detail/access.hpp>
|
||||
#include <boost/spirit/fusion/sequence/detail/tuple_access_result.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <int N>
|
||||
struct tuple_access;
|
||||
}
|
||||
|
||||
namespace tuple_iterator_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct deref_traits_impl
|
||||
{
|
||||
typedef FUSION_GET_INDEX(Iterator) index;
|
||||
typedef FUSION_GET_TUPLE(Iterator) tuple_;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::fusion::detail::tuple_access_result<
|
||||
tuple_, FUSION_GET_VALUE(index)>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename deref_traits_impl<Iterator>::type
|
||||
deref_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return detail::tuple_access<FUSION_GET_VALUE(index)>
|
||||
::get(detail::ref(i.get_tuple()));
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<tuple_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply :
|
||||
tuple_iterator_detail::deref_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_EQUAL_TO_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_EQUAL_TO_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/equal_to.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct has_same_tags
|
||||
: is_same<FUSION_GET_TAG(I1), FUSION_GET_TAG(I2)> {};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct has_same_index
|
||||
: mpl::equal_to<FUSION_GET_INDEX(I1), FUSION_GET_INDEX(I2)>::type {};
|
||||
|
||||
template <typename I>
|
||||
struct tuple_identity
|
||||
{
|
||||
typedef typename I::tuple tuple_type;
|
||||
typedef typename tuple_type::identity_type type;
|
||||
};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct has_same_tuple_identity
|
||||
: is_same<
|
||||
typename tuple_identity<I1>::type
|
||||
, typename tuple_identity<I2>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct tuple_iterator_equal_to
|
||||
: mpl::and_<
|
||||
has_same_index<I1, I2>
|
||||
, has_same_tuple_identity<I1, I2>
|
||||
>
|
||||
{
|
||||
BOOST_STATIC_ASSERT((has_same_tags<I1, I2>::value));
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct equal_to_impl;
|
||||
|
||||
template <>
|
||||
struct equal_to_impl<tuple_iterator_tag>
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct apply : detail::tuple_iterator_equal_to<I1, I2> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_iterator;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct tuple_iterator_next_traits_impl
|
||||
{
|
||||
typedef FUSION_GET_INDEX(Iterator) index;
|
||||
typedef FUSION_GET_TUPLE(Iterator) tuple_;
|
||||
typedef FUSION_GET_SIZE(tuple_) size;
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
BOOST_STATIC_ASSERT((::boost::mpl::less<index, size>::value));
|
||||
#endif
|
||||
typedef typename mpl::next<index>::type next;
|
||||
typedef tuple_iterator<FUSION_GET_VALUE(next), tuple_> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename tuple_iterator_next_traits_impl<Iterator>::type
|
||||
tuple_iterator_next_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return type(detail::ref(i.get_tuple()));
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<tuple_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : detail::tuple_iterator_next_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_PRIOR_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_PRIOR_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/prior.hpp>
|
||||
#include <boost/mpl/greater_equal.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_iterator;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct tuple_iterator_prior_traits_impl
|
||||
{
|
||||
typedef FUSION_GET_INDEX(Iterator) index;
|
||||
typedef FUSION_GET_TUPLE(Iterator) tuple_;
|
||||
typedef FUSION_INT(0) other_index;
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
BOOST_STATIC_ASSERT((
|
||||
::boost::mpl::greater_equal<index, other_index >::value));
|
||||
#endif
|
||||
typedef typename mpl::prior<index>::type prior;
|
||||
typedef tuple_iterator<FUSION_GET_VALUE(prior), tuple_> type;
|
||||
|
||||
static type
|
||||
call(Iterator const& i);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename tuple_iterator_prior_traits_impl<Iterator>::type
|
||||
tuple_iterator_prior_traits_impl<Iterator>::call(Iterator const& i)
|
||||
{
|
||||
return type(detail::ref(i.get_tuple()));
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct prior_impl;
|
||||
|
||||
template <>
|
||||
struct prior_impl<tuple_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : detail::tuple_iterator_prior_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/detail/access.hpp>
|
||||
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <int N>
|
||||
struct tuple_access;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct tuple_iterator_value_traits_impl
|
||||
{
|
||||
typedef FUSION_GET_INDEX(Iterator) index;
|
||||
typedef FUSION_GET_TUPLE(Iterator) tuple_;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
tuple_element<
|
||||
FUSION_GET_VALUE(index), tuple_>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<tuple_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : detail::tuple_iterator_value_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_DEREF_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_DEREF_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/detail/access.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace type_sequence_iterator_detail
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct deref_traits_impl
|
||||
{
|
||||
typedef typename mpl::deref<
|
||||
typename Iterator::iterator_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename deref_traits_impl<Iterator>::type
|
||||
deref_traits_impl<Iterator>::call(Iterator)
|
||||
{
|
||||
FUSION_RETURN_DEFAULT_CONSTRUCTED;
|
||||
}
|
||||
}
|
||||
|
||||
struct type_sequence_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct deref_impl;
|
||||
|
||||
template <>
|
||||
struct deref_impl<type_sequence_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
: type_sequence_iterator_detail::deref_traits_impl<Iterator> {};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_NEXT_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_NEXT_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct type_sequence_iterator_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
struct type_sequence_iterator;
|
||||
|
||||
namespace type_sequence_detail {
|
||||
template <typename Iterator>
|
||||
struct next_traits_impl
|
||||
{
|
||||
typedef type_sequence_iterator<
|
||||
typename mpl::next<typename Iterator::iterator_type>::type
|
||||
> type;
|
||||
|
||||
static type
|
||||
call(Iterator);
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
typename next_traits_impl<Iterator>::type
|
||||
next_traits_impl<Iterator>::call(Iterator)
|
||||
{
|
||||
FUSION_RETURN_DEFAULT_CONSTRUCTED;
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl;
|
||||
|
||||
template <>
|
||||
struct next_impl<type_sequence_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply : type_sequence_detail::next_traits_impl<Iterator>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_VALUE_TRAITS_HPP)
|
||||
#define FUSION_ITERATOR_DETAIL_TYPE_SEQUENCE_ITERATOR_VALUE_TRAITS_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct type_sequence_iterator_tag;
|
||||
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_impl;
|
||||
|
||||
template <>
|
||||
struct value_impl<type_sequence_iterator_tag>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::deref<
|
||||
typename Iterator::iterator_type>::type
|
||||
type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_EQUAL_TO_HPP)
|
||||
#define FUSION_ITERATOR_EQUAL_TO_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct equal_to_impl
|
||||
{
|
||||
template <typename I1, typename I2>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
is_same<
|
||||
typename add_const<I1>::type
|
||||
, typename add_const<I2>::type
|
||||
>::type
|
||||
type;
|
||||
BOOST_STATIC_CONSTANT(bool, value = FUSION_GET_VALUE(type));
|
||||
};
|
||||
};
|
||||
|
||||
template <typename I1, typename I2>
|
||||
struct equal_to
|
||||
: detail::bool_base<
|
||||
typename equal_to_impl<typename as_fusion_iterator<I1>::type::tag>::
|
||||
template apply<
|
||||
typename as_fusion_iterator<I1>::type
|
||||
, typename as_fusion_iterator<I2>::type
|
||||
>::type
|
||||
> {};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_FILTER_VIEW_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_FILTER_VIEW_ITERATOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/filter_view_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/filter_view_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/filter_view_iterator/value_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/filter_view_iterator/equal_to_traits.hpp>
|
||||
#include <boost/spirit/fusion/algorithm/detail/find_if.ipp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_iterator_tag;
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
struct filter_iterator : iterator_base<filter_iterator<First, Last, Pred> >
|
||||
{
|
||||
typedef as_fusion_iterator<First> first_converter;
|
||||
typedef typename first_converter::type first_iter;
|
||||
typedef as_fusion_iterator<Last> last_converter;
|
||||
typedef typename last_converter::type last_iter;
|
||||
|
||||
typedef filter_view_iterator_tag tag;
|
||||
typedef detail::static_find_if<first_iter, last_iter, Pred> filter;
|
||||
typedef typename filter::type first_type;
|
||||
typedef last_iter last_type;
|
||||
typedef Pred pred_type;
|
||||
|
||||
filter_iterator(First const& first);
|
||||
|
||||
first_type first;
|
||||
};
|
||||
|
||||
template <typename First, typename Last, typename Pred>
|
||||
filter_iterator<First,Last,Pred>::filter_iterator(First const& first)
|
||||
: first(filter::call(first_converter::convert(first)))
|
||||
{}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_IS_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_IS_ITERATOR_HPP
|
||||
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// is_iterator metafunction
|
||||
//
|
||||
// Given a type T, returns a value true or false if T is a
|
||||
// fusion iterator or not. Usage:
|
||||
//
|
||||
// is_iterator<T>::value
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
struct iterator_root;
|
||||
|
||||
template <typename T>
|
||||
struct is_iterator : is_base_and_derived<iterator_root, T> {};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_JOINT_VIEW_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_JOINT_VIEW_ITERATOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/joint_view_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/joint_view_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/joint_view_iterator/value_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/equal_to.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct joint_view_iterator_tag;
|
||||
|
||||
template <typename First, typename Last, typename Concat>
|
||||
struct joint_view_iterator
|
||||
: iterator_base<joint_view_iterator<First, Last, Concat> >
|
||||
{
|
||||
typedef as_fusion_iterator<First> first_converter;
|
||||
typedef as_fusion_iterator<Last> last_converter;
|
||||
typedef as_fusion_iterator<Concat> concat_converter;
|
||||
|
||||
typedef typename first_converter::type first_type;
|
||||
typedef typename last_converter::type last_type;
|
||||
typedef typename concat_converter::type concat_type;
|
||||
|
||||
typedef joint_view_iterator_tag tag;
|
||||
#if! BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
||||
BOOST_STATIC_ASSERT((!meta::equal_to<first_type, last_type>::value));
|
||||
#endif
|
||||
joint_view_iterator(First const& first, Concat const& concat);
|
||||
|
||||
first_type first;
|
||||
concat_type concat;
|
||||
};
|
||||
template <typename First, typename Last, typename Concat>
|
||||
joint_view_iterator<First,Last,Concat>::joint_view_iterator(First const& first, Concat const& concat)
|
||||
: first(first_converter::convert(first))
|
||||
, concat(concat_converter::convert(concat))
|
||||
{}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_NEXT_HPP)
|
||||
#define FUSION_ITERATOR_NEXT_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct next_impl
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
// VC6 needs this
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct next
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
typedef typename
|
||||
next_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename meta::next<Iterator>::type
|
||||
next(Iterator const& i)
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
return meta::next_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::call(converter::convert(i));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_PRIOR_HPP)
|
||||
#define FUSION_ITERATOR_PRIOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/config.hpp>
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace meta
|
||||
{
|
||||
template <typename Tag>
|
||||
struct prior_impl
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply {};
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct prior
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
typedef typename
|
||||
prior_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
inline typename meta::prior<Iterator>::type
|
||||
prior(Iterator const& i)
|
||||
{
|
||||
typedef as_fusion_iterator<Iterator> converter;
|
||||
typedef typename converter::type iter;
|
||||
|
||||
return meta::prior_impl<FUSION_GET_TAG(iter)>::
|
||||
template apply<iter>::call(converter::convert(i));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_SINGLE_VIEW_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_SINGLE_VIEW_ITERATOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/detail/access.hpp>
|
||||
#include <boost/spirit/fusion/sequence/detail/as_tuple_element.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/single_view_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/single_view_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/single_view_iterator/value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct single_view_iterator_tag;
|
||||
|
||||
template <typename SingleView>
|
||||
struct single_view_iterator_end
|
||||
: iterator_base<single_view_iterator_end<SingleView> >
|
||||
{
|
||||
typedef single_view_iterator_tag tag;
|
||||
};
|
||||
|
||||
template <typename SingleView>
|
||||
struct single_view_iterator
|
||||
: iterator_base<single_view_iterator<SingleView> >
|
||||
{
|
||||
typedef single_view_iterator_tag tag;
|
||||
typedef SingleView single_view_type;
|
||||
typedef typename add_reference<SingleView>::type reference_type;
|
||||
|
||||
explicit single_view_iterator(reference_type view)
|
||||
: view(view) {}
|
||||
|
||||
reference_type view;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_TRANSFORM_VIEW_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_TRANSFORM_VIEW_ITERATOR_HPP
|
||||
|
||||
#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/transform_view_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/transform_view_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/transform_view_iterator/value_traits.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct transform_view_iterator_tag;
|
||||
|
||||
template <typename First, typename F>
|
||||
struct transform_view_iterator
|
||||
: iterator_base<transform_view_iterator<First, F> >
|
||||
{
|
||||
typedef transform_view_iterator_tag tag;
|
||||
typedef as_fusion_iterator<First> converter;
|
||||
typedef typename converter::type first_type;
|
||||
typedef F transform_type;
|
||||
|
||||
transform_view_iterator(First const& first, F f);
|
||||
|
||||
first_type first;
|
||||
transform_type f;
|
||||
};
|
||||
|
||||
template <typename First, typename F>
|
||||
transform_view_iterator<First,F>::transform_view_iterator(First const& first, F f)
|
||||
: first(converter::convert(first)), f(f) {}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2003 Joel de Guzman
|
||||
Copyright (c) 2004 Peder Holt
|
||||
|
||||
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)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_ITERATOR_TUPLE_ITERATOR_HPP)
|
||||
#define FUSION_ITERATOR_TUPLE_ITERATOR_HPP
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/tuple_iterator/deref_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/tuple_iterator/value_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/tuple_iterator/next_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/tuple_iterator/prior_traits.hpp>
|
||||
#include <boost/spirit/fusion/iterator/detail/tuple_iterator/equal_to_traits.hpp>
|
||||
#include <boost/spirit/fusion/sequence/detail/tuple_begin_end_traits.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tuple_iterator_tag;
|
||||
struct void_t;
|
||||
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_iterator;
|
||||
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_iterator_base : iterator_base<tuple_iterator<N, Tuple> >
|
||||
{
|
||||
typedef FUSION_INT(N) index;
|
||||
typedef Tuple tuple;
|
||||
typedef tuple_iterator_tag tag;
|
||||
typedef tuple_iterator<N, Tuple> self_type;
|
||||
};
|
||||
|
||||
template <int N, typename Tuple>
|
||||
struct tuple_iterator : tuple_iterator_base<N,Tuple>
|
||||
{
|
||||
typedef typename tuple_iterator_base<N,Tuple>::tuple tuple;
|
||||
typedef typename tuple_iterator_base<N,Tuple>::index index;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
mpl::less<index, typename Tuple::size>
|
||||
, detail::tuple_iterator_next_traits_impl<tuple_iterator_base<N,Tuple> >
|
||||
, mpl::identity<void_t>
|
||||
>::type
|
||||
next;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
mpl::less<index, typename Tuple::size>
|
||||
, detail::tuple_iterator_value_traits_impl<tuple_iterator_base<N,Tuple> >
|
||||
, mpl::identity<void_t>
|
||||
>::type
|
||||
type;
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
tuple_iterator(tuple_iterator const& i);
|
||||
#else
|
||||
template <int N2, typename Tuple2>
|
||||
tuple_iterator(tuple_iterator<N2, Tuple2> const& i)
|
||||
: t(static_cast<tuple&>(i.get_tuple())) {}
|
||||
#endif
|
||||
tuple_iterator(tuple& t);
|
||||
|
||||
tuple&
|
||||
get_tuple() const;
|
||||
private:
|
||||
|
||||
tuple& t;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template <int N, typename Tuple>
|
||||
tuple_iterator<N,Tuple>::tuple_iterator(tuple_iterator const& i)
|
||||
: t(static_cast<tuple&>(i.get_tuple())) {}
|
||||
#endif
|
||||
|
||||
template <int N, typename Tuple>
|
||||
tuple_iterator<N,Tuple>::tuple_iterator(tuple& t)
|
||||
: t(t) {}
|
||||
|
||||
template <int N, typename Tuple>
|
||||
typename tuple_iterator<N,Tuple>::tuple&
|
||||
tuple_iterator<N,Tuple>::get_tuple() const
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user