Compare commits

..

1 Commits

Author SHA1 Message Date
da51b3bd95 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r35906]
2006-11-07 19:11:58 +00:00
1334 changed files with 0 additions and 154355 deletions

View File

@ -1,225 +0,0 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2017-2018 Kohei Takahashi
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
os:
- linux
- osx
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
# trusty default (gcc 4.8.4)
- os: linux
env: TOOLSET=gcc CXXSTD=03,11,1y
- os: linux
env: TOOLSET=gcc-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
- os: linux
env: TOOLSET=gcc-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
- os: linux
env: TOOLSET=gcc-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
- os: linux
env: TOOLSET=gcc-4.8 CXXSTD=03,11,1y
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc-4.9 CXXSTD=03,11,1y
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=gcc-7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
# trusty default (clang 3.9.0)
- os: linux
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=clang-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=clang-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
env: TOOLSET=clang-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
env: TOOLSET=clang-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=clang-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
env: TOOLSET=clang-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
env: TOOLSET=clang-5.0 CXXSTD=03,11,14,1z,2a
addons:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: osx
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/array
- git submodule init libs/assert
- git submodule init libs/bind
- git submodule init libs/concept_check
- git submodule init libs/config
- git submodule init libs/container_hash
- git submodule init libs/conversion
- git submodule init libs/core
- git submodule init libs/detail
- git submodule init libs/function
- git submodule init libs/function_types
- git submodule init libs/functional
- git submodule init libs/integer
- git submodule init libs/iterator
- git submodule init libs/lambda
- git submodule init libs/move
- git submodule init libs/mpl
- git submodule init libs/optional
- git submodule init libs/predef
- git submodule init libs/preprocessor
- git submodule init libs/smart_ptr
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/tuple
- git submodule init libs/type_index
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/utility
- git submodule init tools/build
- git submodule update
- rm -rf libs/fusion
- mv $TRAVIS_BUILD_DIR libs/fusion
- ln -s $(pwd)/libs/fusion $TRAVIS_BUILD_DIR
- ./bootstrap.sh
- ./b2 headers
script:
- ./b2 -j`(nproc || sysctl -n hw.ncpu) 2> /dev/null` libs/fusion/test toolset=$TOOLSET cxxstd=$CXXSTD

View File

@ -1,85 +0,0 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2017-2018 Kohei Takahashi
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-10.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-11.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-12.0
CXXSTD: latest # fake
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
CXXSTD: latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: latest
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone --depth 1 -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/array
- git submodule init libs/assert
- git submodule init libs/bind
- git submodule init libs/concept_check
- git submodule init libs/config
- git submodule init libs/container_hash
- git submodule init libs/conversion
- git submodule init libs/core
- git submodule init libs/detail
- git submodule init libs/function
- git submodule init libs/function_types
- git submodule init libs/functional
- git submodule init libs/integer
- git submodule init libs/iterator
- git submodule init libs/lambda
- git submodule init libs/move
- git submodule init libs/mpl
- git submodule init libs/optional
- git submodule init libs/predef
- git submodule init libs/preprocessor
- git submodule init libs/smart_ptr
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/tuple
- git submodule init libs/type_index
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/utility
- git submodule init tools/build
- git submodule update
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\fusion
- cmd /c bootstrap
- b2 headers
build: off
test_script:
- b2 -j%NUMBER_OF_PROCESSORS% --hash libs/fusion/test toolset=%TOOLSET% cxxstd=%CXXSTD%

View File

@ -1,32 +0,0 @@
#==============================================================================
# Copyright (c) 2003-2011 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)
#==============================================================================
project boost/libs/fusion/doc ;
import boostbook : boostbook ;
using quickbook ;
path-constant images_location : html ;
boostbook quickbook
:
fusion.qbk
:
<xsl:param>boost.root=../../../..
<xsl:param>chunk.section.depth=4
<xsl:param>chunk.first.sections=1
<xsl:param>toc.section.depth=3
<xsl:param>toc.max.depth=3
<xsl:param>generate.section.toc.level=4
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/fusion/doc/html
<format>pdf:<xsl:param>img.src.path=$(images_location)/
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : quickbook ;
explicit boostrelease ;

View File

@ -1,24 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Acknowledgements]
Special thanks to David Abrahams, Douglas Gregor, Hartmut Kaiser, Aleksey
Gurtovoy, Peder Holt, Daniel Wallin, Jaakko Jarvi, Jeremiah Willcock, Dan
Marsden, Eric Niebler, Joao Abecasis and Andy Little. These people are
instrumental in the design and development of Fusion.
Special thanks to Ronald Garcia, the review manager and to all the people in the
boost community who participated in the review: Andreas Pokorny, Andreas Huber,
Jeff Flinn, David Abrahams, Pedro Lamarao, Larry Evans, Ryan Gallagher, Andy
Little, Gennadiy Rozental, Tobias Schwinger, Joao Abecasis, Eric Niebler, Oleg
Abrosimov, Gary Powell, Eric Friedman, Darren Cook, Martin Bonner and Douglas
Gregor.
[endsect]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 Dan Marsden
Copyright (C) 2006 Tobias Schwinger
Copyright (C) 2010 Christopher Schmidt
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)
===============================================================================/]
[section Change log]
This section summarizes significant changes to the Fusion library.
* Sep 27, 2006: Added `boost::tuple` support. (Joel de Guzman)
* Nov 17, 2006: Added `boost::variant` support. (Joel de Guzman)
* Feb 15, 2007: Added functional module. (Tobias Schwinger)
* April 2, 2007: Added struct adapter. (Joel de Guzman)
* May 8, 2007: Added associative struct adapter. (Dan Marsden)
* Dec 20, 2007: Removed `boost::variant` support. After thorough
investigation, I think now that the move to make variant a
fusion sequence is rather quirky. A variant will always
have a size==1 regardless of the number of types it can contain
and there's no way to know at compile time what it contains.
Iterating over its types is simply wrong. All these imply that
the variant is *not* a fusion sequence. (Joel de Guzman)
* Oct 12, 2009: The accumulator is the first argument to the functor of
__fold__ and __accumulate__. (Christopher Schmidt)
* Oct 30, 2009: Added support for associative iterators and views. (Christopher
Schmidt)
* March 1, 2010: Added __adapt_struct_named__ and __adapt_struct_named_ns__
(Hartmut Kaiser)
* April 4, 2010: Added __array__ support, __adapt_tpl_struct__,
__adapt_assoc_tpl_struct__, __adapt_assoc_struct_named__ and
__adapt_assoc_struct_named_ns__ (Christopher Schmidt)
* April 5, 2010: Added __define_struct__, __define_tpl_struct__,
__define_assoc_struct__ and __define_assoc_tpl_struct__ (Christopher Schmidt)
* June 18, 2010: Added __reverse_fold__, __iter_fold__ and __reverse_iter_fold__
(Christopher Schmidt)
* October 7, 2010: Added __adapt_adt__, __adapt_tpl_adt__,
__adapt_assoc_adt__ and __adapt_assoc_tpl_adt__ (Joel de Guzman,
Hartmut Kaiser and Christopher Schmidt)
* August 29, 2011: Added support for segmented sequences and iterators (Eric Niebler)
* September 16, 2011: Added preprocessed files (using wave) to speed up
compilation (Joel de Guzman)
* October 8, 2011: Added adaptor for std::tuple (Joel de Guzman)
* October 10, 2011: Made map random access (Brandon Kohn)
* April 7, 2012: Added C++11 version of deque
* May 19, 2012: Added BOOST_FUSION_DEFINE_STRUCT_INLINE by Nathan Ridge
* September 1, 2012: Added move support for deque and vector
[endsect]

File diff suppressed because it is too large Load Diff

View File

@ -1,490 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Extension]
[section:ext_full The Full Extension Mechanism]
The Fusion library is designed to be extensible, new sequences types can easily
be added. In fact, the library support for `std::pair`, `boost::array` and __mpl__
sequences is entirely provided using the extension mechanism.
The process for adding a new sequence type to Fusion is:
# Enable the __tag_dispatching__ mechanism used by Fusion for your sequence type
# Design an iterator type for the sequence
# Provide specialized behaviour for the intrinsic operations of the new Fusion sequence
[heading Our example]
In order to illustrate enabling a new sequence type for use with Fusion, we
are going to use the type:
namespace example
{
struct example_struct
{
std::string name;
int age;
example_struct(
const std::string& n,
int a)
: name(n), age(a)
{}
};
}
We are going to pretend that this type has been provided by a 3rd party
library, and therefore cannot be modified. We shall work through all the
necessary steps to enable `example_struct` to serve as an __associative_sequence__
as described in the __quick_start__ guide.
[heading Enabling Tag Dispatching]
The Fusion extensibility mechanism uses __tag_dispatching__ to call the
correct code for a given sequence type. In order to exploit the tag
dispatching mechanism we must first declare a new tag type for the
mechanism to use. For example:
namespace example {
struct example_sequence_tag; // Only definition needed
}
Next we need to enable the `traits::tag_of` metafunction to return our newly chosen
tag type for operations involving our sequence. This is done by specializing
`traits::tag_of` for our sequence type.
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/fusion/include/tag_of_fwd.hpp>
namespace boost { namespace fusion { namespace traits {
template<>
struct tag_of<example_struct>
{
typedef example::example_sequence_tag type;
};
}}}
`traits::tag_of` also has a second template argument,
that can be used in conjunction with `boost::enable_if` to provide tag
support for groups of related types. This feature is not necessary
for our sequence, but for an example see the code in:
#include <boost/fusion/adapted/array/tag_of.hpp>
#include <boost/fusion/include/tag_of.hpp>
[heading Designing a suitable iterator]
We need an iterator to describe positions, and provide access to
the data within our sequence. As it is straightforward to do,
we are going to provide a random access iterator in our example.
We will use a simple design, in which the 2 members of
`example_struct` are given numbered indices, 0 for `name` and
1 for `age` respectively.
template<typename Struct, int Pos>
struct example_struct_iterator
: boost::fusion::iterator_base<example_struct_iterator<Struct, Pos> >
{
BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
typedef Struct struct_type;
typedef boost::mpl::int_<Pos> index;
typedef boost::fusion::random_access_traversal_tag category;
example_struct_iterator(Struct& str)
: struct_(str) {}
Struct& struct_;
};
A quick summary of the details of our iterator:
# The iterator is parameterized by the type it is iterating over, and the index of the current element.
# The typedefs `struct_type` and `index` provide convenient access to information we will need later in
the implementation.
# The typedef `category` allows the `traits::__category_of__` metafunction to establish
the traversal category of the iterator.
# The constructor stores a reference to the `example_struct` being iterated over.
We also need to enable __tag_dispatching__ for our iterator type, with another specialization of
`traits::tag_of`.
In isolation, the iterator implementation is pretty dry. Things should become clearer as we
add features to our implementation.
[heading A first couple of instructive features]
To start with, we will get the __result_of_value_of__ metafunction working. To
do this, we provide a specialization of the `boost::fusion::extension::value_of_impl` template for
our iterator's tag type.
template<>
struct value_of_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef std::string type;
};
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef int type;
};
};
The implementation itself is pretty simple, it just uses 2 partial specializations to
provide the type of the 2 different members of `example_struct`, based on the index of the iterator.
To understand how `value_of_impl` is used by the library we will look at the implementation of __result_of_value_of__:
template <typename Iterator>
struct value_of
: extension::value_of_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
So __result_of_value_of__ uses __tag_dispatching__ to select an __mpl_metafunction_class__
to provide its functionality. You will notice this pattern throughout the
implementation of Fusion.
Ok, lets enable dereferencing of our iterator. In this case we must provide a suitable
specialization of `deref_impl`.
template<>
struct deref_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef typename mpl::if_<
is_const<Struct>, std::string const&, std::string&>::type type;
static type
call(example::example_struct_iterator<Struct, 0> const& it)
{
return it.struct_.name;
}
};
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef typename mpl::if_<
is_const<Struct>, int const&, int&>::type type;
static type
call(example::example_struct_iterator<Struct, 1> const& it)
{
return it.struct_.age;
}
};
};
}
The use of `deref_impl` is very similar to that of `value_of_impl`, but it also
provides some runtime functionality this time via the `call` static member function.
To see how `deref_impl` is used, lets have a look at the implementation of __deref__:
namespace result_of
{
template <typename Iterator>
struct __deref__
: extension::deref_impl<typename detail::tag_of<Iterator>::type>::
template apply<Iterator>
{};
}
template <typename Iterator>
typename result_of::deref<Iterator>::type
__deref__(Iterator const& i)
{
typedef result_of::deref<Iterator> deref_meta;
return deref_meta::call(i);
}
So again __result_of_deref__ uses __tag_dispatching__ in exactly the
same way as the __result_of_value_of__ implementation. The runtime functionality used
by __deref__ is provided by the `call` static function of the selected
__mpl_metafunction_class__.
The actual implementation of `deref_impl` is slightly more complex than that of `value_of_impl`.
We also need to implement the `call` function, which returns a reference
to the appropriate member of the underlying sequence. We also require a little
bit of metaprogramming to return `const` references if the underlying sequence
is const.
[note Although there is a fair amount of left to do to produce a fully fledged
Fusion sequence, __result_of_value_of__ and __deref__ illustrate all the significant concepts
required. The remainder of the process is very repetitive, simply requiring
implementation of a suitable `xxxx_impl` for each feature `xxxx`.
]
[heading Implementing the remaining iterator functionality]
Ok, now we have seen the way __result_of_value_of__ and __deref__ work, everything else will work
in pretty much the same way. Lets start with forward iteration,
by providing a `next_impl`:
template<>
struct next_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example::example_struct_iterator<struct_type, index::value + 1> type;
static type
call(Iterator const& i)
{
return type(i.struct_);
}
};
};
This should be very familiar from our `deref_impl` implementation, we will be
using this approach again and again now. Our design is simply to increment
the `index` counter to move on to the next element. The various other iterator
manipulations we need to perform will all just involve simple calculations
with the `index` variables.
We also need to provide a suitable `equal_to_impl` so that iterators can be
correctly compared. A __bidirectional_iterator__ will also need an implementation of `prior_impl`. For a
__random_access_iterator__ `distance_impl` and `advance_impl` also need to be provided
in order to satisfy the necessary complexity guarantees. As our iterator is
a __random_access_iterator__ we will have to implement all of these functions.
Full implementations of `prior_impl`, `advance_impl`, `distance_impl` and `equal_to_impl` are
provided in the example code.
[heading Implementing the intrinsic functions of the sequence]
In order that Fusion can correctly identify our sequence as a Fusion sequence, we
need to enable `is_sequence` for our sequence type. As usual we just create
an `impl` type specialized for our sequence tag:
template<>
struct is_sequence_impl<example::example_sequence_tag>
{
template<typename T>
struct apply : mpl::true_ {};
};
We've some similar formalities to complete, providing `category_of_impl` so Fusion
can correctly identify our sequence type, and `is_view_impl` so Fusion can correctly
identify our sequence as not being a __view__ type. Implementations are
provide in the example code.
Now we've completed some formalities, on to more interesting features. Lets get
__begin__ working so that we can get an iterator to start accessing the data in
our sequence.
template<>
struct begin_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef example::example_struct_iterator<Sequence, 0> type;
static type
call(Sequence& seq)
{
return type(seq);
}
};
};
The implementation uses the same ideas we have applied throughout, in this case
we are just creating one of the iterators we developed earlier, pointing to the
first element in the sequence. The implementation of __end__ is very similar, and
is provided in the example code.
For our __random_access_sequence__ we will also need to implement `size_impl`,
`value_at_impl` and `at_impl`.
[heading Enabling our type as an associative sequence]
In order for `example_struct` to serve as an associative forward sequence,
we need to adapt the traversal category of our sequence and our iterator
accordingly and enable 3 intrinsic sequence lookup features, __at_key__,
__result_of_value_at_key__ and __has_key__. We also need to enable 3 iterator lookup
features, __result_of_key_of__, __result_of_value_of_data__ and __deref_data__.
To implement `at_key_impl` we need to associate the `fields::name` and `fields::age`
types described in the __quick_start__ guide with the appropriate members of `example_struct`.
Our implementation is as follows:
template<>
struct at_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply;
template<typename Sequence>
struct apply<Sequence, fields::name>
{
typedef typename mpl::if_<
is_const<Sequence>,
std::string const&,
std::string&>::type type;
static type
call(Sequence& seq)
{
return seq.name;
};
};
template<typename Sequence>
struct apply<Sequence, fields::age>
{
typedef typename mpl::if_<
is_const<Sequence>,
int const&,
int&>::type type;
static type
call(Sequence& seq)
{
return seq.age;
};
};
};
Its all very similar to the implementations we've seen previously,
such as `deref_impl` and `value_of_impl`. Instead of identifying
the members by index or position, we are now selecting them using
the types `fields::name` and `fields::age`. The implementations of
the other functions are equally straightforward, and are provided in
the example code.
[heading Summary]
We've now worked through the entire process for adding a new random
access sequence and we've also enabled our type to serve as an associative
sequence. The implementation was slightly long-winded, but followed
a simple repeating pattern.
The support for `std::pair`, __mpl__ sequences, and `boost::array` all
use the same approach, and provide additional examples of the approach
for a variety of types.
[endsect]
[section Sequence Facade]
[heading Description]
The __sequence_facade__ template provides an intrusive mechanism for
producing a conforming Fusion sequence.
[heading Synopsis]
template<typename Derived, typename TravesalTag, typename IsView = mpl::false_>
struct sequence_facade;
[heading Usage]
The user of __sequence_facade__ derives his sequence type from a specialization of __sequence_facade__ and passes the derived sequence type as the first template parameter. The second template parameter should be the traversal category of the sequence being implemented. The 3rd parameter should be set to `mpl::true_` if the sequence is a view.
The user must implement the key expressions required by their sequence type.
[table Parameters
[[Name][Description]]
[[`sequence`, `Seq`][A type derived from __sequence_facade__]]
[[`N`][An __mpl_integral_constant__]]
]
[table Key Expressions
[[Expression][Result]]
[[`sequence::template begin<Seq>::type`][The type of an iterator to the beginning of a sequence of type `Seq`]]
[[`sequence::template begin<Seq>::call(seq)`][An iterator to the beginning of sequence `seq`]]
[[`sequence::template end<Seq>::type`][The type of an iterator to the end of a sequence of type `Seq`]]
[[`sequence::template end<Seq>::call(seq)`][An iterator to the end of sequence `seq`]]
[[`sequence::template size<Seq>::type`][The size of a sequence of type `Seq` as an __mpl_integral_constant__]]
[[`sequence::template size<Seq>::call(seq)`][The size of sequence `seq`]]
[[`sequence::template empty<Seq>::type`][Returns `mpl::true_` if `Seq` has zero elements, `mpl::false_` otherwise.]]
[[`sequence::template empty<Seq>::call`][Returns a type convertible to `bool` that evaluates to true if the sequence is empty, else, evaluates to false. ]]
[[`sequence::template at<Seq, N>::type`][The type of element `N` in a sequence of type `Seq`]]
[[`sequence::template at<Seq, N>::call(seq)`][Element `N` in sequence `seq`]]
[[`sequence::template value_at<Sequence, N>::type`][The type of the `N`th element in a sequence of type `Seq`]]
]
[heading Include]
#include <boost/fusion/sequence/sequence_facade.hpp>
#include <boost/fusion/include/sequence_facade.hpp>
[heading Example]
A full working example using __sequence_facade__ is provided in triple.cpp in the extension examples.
[endsect]
[section Iterator Facade]
[heading Description]
The __iterator_facade__ template provides an intrusive mechanism for
producing a conforming Fusion iterator.
[heading Synopsis]
template<typename Derived, typename TravesalTag>
struct iterator_facade;
[heading Usage]
The user of iterator_facade derives his iterator type from a specialization of iterator_facade and passes the derived iterator type as the first template parameter. The second template parameter should be the traversal category of the iterator being implemented.
The user must implement the key expressions required by their iterator type.
[table Parameters
[[Name][Description]]
[[`iterator`, `It`, `It1`, `It2`][A type derived from __iterator_facade__]]
[[`N`][An __mpl_integral_constant__]]
]
[table Key Expressions
[[Expression][Result][Default]]
[[`iterator::template value_of<It>::type`][The element stored at iterator position `It`][None]]
[[`iterator::template deref<It>::type`][The type returned when dereferencing an iterator of type `It`][None]]
[[`iterator::template deref<It>::call(it)`][Dereferences iterator `it`][None]]
[[`iterator::template next<It>::type`][The type of the next element from `It`][None]]
[[`iterator::template next<It>::call(it)`][The next iterator after `it`][None]]
[[`iterator::template prior<It>::type`][The type of the next element from `It`][None]]
[[`iterator::template prior<It>::call(it)`][The next iterator after `it`][None]]
[[`iterator::template advance<It, N>::type`][The type of an iterator advanced `N` elements from `It`][Implemented in terms of `next` and `prior`]]
[[`iterator::template advance<It, N>::call(it)`][An iterator advanced `N` elements from `it`][Implemented in terms of `next` and `prior`]]
[[`iterator::template distance<It1, It2>::type`][The distance between iterators of type `It1` and `It2` as an __mpl_integral_constant__][None]]
[[`iterator::template distance<It1, It2>::call(it1, it2)`][The distance between iterator `it1` and `it2`][None]]
[[`iterator::template equal_to<It1, It2>::type`][Returns `mpl::true_` if `It1` is equal to `It2`, `mpl::false_` otherwise.][`boost::same_type<It1, It2>::type`]]
[[`iterator::template equal_to<It1, It2>::call(it1, it2)`][Returns a type convertible to `bool` that evaluates to `true` if `It1` is equal to `It2`, `false` otherwise.][`boost::same_type<It1, It2>::type()`]]
[[`iterator::template key_of<It>::type`][The key type associated with the element from `It`][None]]
[[`iterator::template value_of_data<It>::type`][The type of the data property associated with the element from `It`][None]]
[[`iterator::template deref_data<It>::type`][The type that will be returned by dereferencing the data property of the element from `It`][None]]
[[`iterator::template deref_data<It>::call(it)`][Deferences the data property associated with the element referenced by `it`][None]]
]
[heading Header]
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/fusion/include/iterator_facade.hpp>
[heading Example]
A full working example using __iterator_facade__ is provided in triple.cpp in the extension examples.
[endsect]
[endsect]

File diff suppressed because it is too large Load Diff

View File

@ -1,361 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 Dan Marsden
Copyright (C) 2010 Christopher Schmidt
Copyright (C) 2018 Kohei Takahashi
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)
===============================================================================/]
[library Fusion
[quickbook 1.3]
[version 2.2]
[authors [de Guzman, Joel], [Marsden, Dan], [Schwinger, Tobias]]
[copyright 2001 2002 2003 2004 2005 2006 2011 2012 Joel de Guzman, Dan Marsden, Tobias Schwinger]
[purpose Statically Typed Heterogeneous Data Structures and Algorithms]
[license
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
[@http://www.boost.org/LICENSE_1_0.txt])
]
]
[def __spirit__ [@http://boost-spirit.com/home/ Spirit]]
[def __phoenix__ [@http://www.boost.org/libs/phoenix Phoenix]]
[def __mpl__ [@http://www.boost.org/libs/mpl MPL]]
[def __stl__ [@http://en.wikipedia.org/wiki/Standard_Template_Library STL]]
[def __tuple__ [@http://www.boost.org/libs/tuple Boost.Tuple]]
[def __tr1__tuple__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1403.pdf TR1 Tuple]]
[def __boost_tools__ [@http://www.boost.org/tools/index.html Boost Tools]]
[def __spirit_list__ [@https://sourceforge.net/projects/spirit/lists/spirit-general Spirit Mailing List]]
[def __list_archive__ [@https://sourceforge.net/p/spirit/mailman/spirit-general/ archive]]
[def __jaakko_jarvi__ [@http://www.boost.org/people/jaakko_jarvi.htm Jaakko Jarvi]]
[def __david_abrahams__ [@http://www.boost.org/people/dave_abrahams.htm David Abrahams]]
[def __the_forwarding_problem__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm The Forwarding Problem]]
[def __boost_any__ [@http://www.boost.org/libs/any Boost.Any Library]]
[def __new_iterator_concepts__ [@http://www.boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts]]
[def __boost_array_library__ [@http://www.boost.org/libs/array Boost.Array Library]]
[def __boost_variant_library__ [@http://www.boost.org/libs/variant Boost.Variant Library]]
[def __boost_tuple_library__ [@http://www.boost.org/libs/tuple Boost.Tuple Library]]
[def __boost_ref__ [@http://www.boost.org/libs/core/ref.html Ref utility]]
[def __boost_ref_call__ [@http://www.boost.org/libs/core/ref.html `ref`]]
[def __boost_result_of__ [@http://www.boost.org/libs/utility/utility.htm#result_of ResultOf utility]]
[def __boost_result_of_call__ [@http://www.boost.org/libs/utility/utility.htm#result_of `boost::result_of`]]
[def __boost_enable_if__ [@http://www.boost.org/libs/core/doc/html/core/enable_if.html EnableIf utility]]
[def __boost_shared_ptr_call__ [@http://www.boost.org/libs/smart_ptr#shared_ptr `boost::shared_ptr`]]
[def __boost_func_forward__ [@http://www.boost.org/libs/functional/forward Boost.Functional/Forward Library]]
[def __boost_func_factory__ [@http://www.boost.org/libs/functional/factory Boost.Functional/Factory Library]]
[def __boost_func_hash__ [@http://www.boost.org/doc/html/hash.html Boost.ContainerHash Library]]
[def __std_pair_doc__ [@http://en.cppreference.com/w/cpp/utility/pair `std::pair`]]
[def __std_tuple_doc__ [@http://en.cppreference.com/w/cpp/utility/tuple `std::tuple`]]
[def __std_plus_doc__ [@http://en.cppreference.com/w/cpp/utility/functional/plus `std::plus`]]
[def __std_minus_doc__ [@http://en.cppreference.com/w/cpp/utility/functional/minus `std::minus`]]
[def __mpl_integral_constant__ [@http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html MPL Integral Constant]]
[def __mpl_boolean_constant__ [@http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html MPL Boolean Constant]]
[def __mpl_metafunction_class__ [@http://www.boost.org/libs/mpl/doc/refmanual/metafunction-class.html MPL Metafunction Class]]
[def __mpl_lambda_expression__ [@http://www.boost.org/libs/mpl/doc/refmanual/lambda-expression.html MPL Lambda Expression]]
[def __lvalue__ LValue]
[def __unspecified__ /unspecified/]
[def __support__ [link fusion.support Support]]
[def __is_sequence__ [link fusion.support.is_sequence `is_sequence`]]
[def __is_view__ [link fusion.support.is_view `is_view`]]
[def __tag_of__ [link fusion.support.tag_of `tag_of`]]
[def __category_of__ [link fusion.support.category_of `category_of`]]
[def __deduce__ [link fusion.support.deduce `deduce`]]
[def __deduce_sequence__ [link fusion.support.deduce_sequence `deduce_sequence`]]
[def __fusion_pair__ [link fusion.support.pair `fusion::pair`]]
[def __pair__ [link fusion.support.pair `pair`]]
[def __fusion_make_pair__ [link fusion.support.pair `make_pair`]]
[def __iterator__ [link fusion.iterator Iterator]]
[def __iterator_concepts__ [link fusion.iterator.concepts Iterator Concepts]]
[def __forward_iterator__ [link fusion.iterator.concepts.forward_iterator Forward Iterator]]
[def __bidirectional_iterator__ [link fusion.iterator.concepts.bidirectional_iterator Bidirectional Iterator]]
[def __random_access_iterator__ [link fusion.iterator.concepts.random_access_iterator Random Access Iterator]]
[def __associative_iterator__ [link fusion.iterator.concepts.associative_iterator Associative Iterator]]
[def __unbounded_iterator__ [link fusion.iterator.concepts.unbounded_iterator Unbounded Iterator]]
[def __next__ [link fusion.iterator.functions.next `next`]]
[def __prior__ [link fusion.iterator.functions.prior `prior`]]
[def __advance__ [link fusion.iterator.functions.advance `advance`]]
[def __advance_c__ [link fusion.iterator.functions.advance_c `advance_c`]]
[def __distance__ [link fusion.iterator.functions.distance `distance`]]
[def __deref__ [link fusion.iterator.functions.deref `deref`]]
[def __deref_data__ [link fusion.iterator.functions.deref_data `deref_data`]]
[def __result_of_next__ [link fusion.iterator.metafunctions.next `result_of::next`]]
[def __result_of_prior__ [link fusion.iterator.metafunctions.prior `result_of::prior`]]
[def __result_of_equal_to__ [link fusion.iterator.metafunctions.equal_to `result_of::equal_to`]]
[def __result_of_advance__ [link fusion.iterator.metafunctions.advance `result_of::advance`]]
[def __result_of_advance_c__ [link fusion.iterator.metafunctions.advance_c `result_of::advance_c`]]
[def __result_of_distance__ [link fusion.iterator.metafunctions.distance `result_of::distance`]]
[def __result_of_deref__ [link fusion.iterator.metafunctions.deref `result_of::deref`]]
[def __result_of_value_of__ [link fusion.iterator.metafunctions.value_of `result_of::value_of`]]
[def __result_of_key_of__ [link fusion.iterator.metafunctions.key_of `result_of::key_of`]]
[def __result_of_value_of_data__ [link fusion.iterator.metafunctions.value_of_data `result_of::value_of_data`]]
[def __result_of_deref_data__ [link fusion.iterator.metafunctions.deref_data `result_of::deref_data`]]
[def __sequence__ [link fusion.sequence Sequence]]
[def __sequence_concepts__ [link fusion.sequence.concepts Sequence Concepts]]
[def __traversal_concept__ [link fusion.sequence.concepts.traversal Sequence Traversal Concept]]
[def __associativity_concept__ [link fusion.sequence.concepts.associativity Sequence Associativity Concept]]
[def __forward_sequence__ [link fusion.sequence.concepts.forward_sequence Forward Sequence]]
[def __bidirectional_sequence__ [link fusion.sequence.concepts.bidirectional_sequence Bidirectional Sequence]]
[def __random_access_sequence__ [link fusion.sequence.concepts.random_access_sequence Random Access Sequence]]
[def __associative_sequence__ [link fusion.sequence.concepts.associative_sequence Associative Sequence]]
[def __unbounded_sequence__ [link fusion.sequence.concepts.unbounded_sequence Unbounded Sequence]]
[def __containers__ [link fusion.container Container]]
[def __vector__ [link fusion.container.vector `vector`]]
[def __cons__ [link fusion.container.cons `cons`]]
[def __list__ [link fusion.container.list `list`]]
[def __deque__ [link fusion.container.deque `deque`]]
[def __front_extended_deque__ [link fusion.container.front_extended_deque `front_extended_deque`]]
[def __back_extended_deque__ [link fusion.container.back_extended_deque `back_extended_deque`]]
[def __set__ [link fusion.container.set `set`]]
[def __map__ [link fusion.container.map `map`]]
[def __view__ [link fusion.view View]]
[def __views__ [link fusion.view Views]]
[def __single_view__ [link fusion.view.single_view `single_view`]]
[def __filter_view__ [link fusion.view.filter_view `filter_view`]]
[def __iterator_range__ [link fusion.view.iterator_range `iterator_range`]]
[def __joint_view__ [link fusion.view.joint_view `joint_view`]]
[def __transform_view__ [link fusion.view.transform_view `transform_view`]]
[def __reverse_view__ [link fusion.view.reverse_view `reverse_view`]]
[def __zip_view__ [link fusion.view.zip_view `zip_view`]]
[def __flatten_view__ [link fusion.view.flatten_view `flatten_view`]]
[def __array__ [link fusion.adapted.array array]]
[def __std_pair__ [link fusion.adapted.std__pair `std::pair`]]
[def __boost_array__ [link fusion.adapted.boost__array `boost::array`]]
[def __mpl_sequence__ [link fusion.adapted.mpl_sequence mpl sequence]]
[def __adapt_tpl_struct__ [link fusion.adapted.adapt_tpl_struct `BOOST_FUSION_ADAPT_TPL_STRUCT`]]
[def __adapt_struct_named__ [link fusion.adapted.adapt_struct_named `BOOST_FUSION_ADAPT_STRUCT_NAMED`]]
[def __adapt_struct_named_ns__ [link fusion.adapted.adapt_struct_named `BOOST_FUSION_ADAPT_STRUCT_NAMED_NS`]]
[def __adapt_assoc_tpl_struct__ [link fusion.adapted.adapt_assoc_tpl_struct `BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT`]]
[def __adapt_assoc_struct_named__ [link fusion.adapted.adapt_assoc_struct_named `BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED`]]
[def __adapt_assoc_struct_named_ns__ [link fusion.adapted.adapt_assoc_struct_named `BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED_NS`]]
[def __adapt_adt__ [link fusion.adapted.adapt_adt `BOOST_FUSION_ADAPT_ADT`]]
[def __adapt_tpl_adt__ [link fusion.adapted.adapt_tpl_adt `BOOST_FUSION_ADAPT_TPL_ADT`]]
[def __adapt_assoc_adt__ [link fusion.adapted.adapt_assoc_adt `BOOST_FUSION_ADAPT_ASSOC_ADT`]]
[def __adapt_assoc_tpl_adt__ [link fusion.adapted.adapt_assoc_tpl_adt `BOOST_FUSION_ADAPT_ASSOC_TPL_ADT`]]
[def __define_struct__ [link fusion.adapted.define_struct `BOOST_FUSION_DEFINE_STRUCT`]]
[def __define_tpl_struct__ [link fusion.adapted.define_tpl_struct `BOOST_FUSION_DEFINE_TPL_STRUCT`]]
[def __define_assoc_struct__ [link fusion.adapted.define_assoc_struct `BOOST_FUSION_DEFINE_ASSOC_STRUCT`]]
[def __define_assoc_tpl_struct__ [link fusion.adapted.define_assoc_tpl_struct `BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT`]]
[def __intrinsic__ [link fusion.sequence.intrinsic Intrinsic]]
[def __intrinsics__ [link fusion.sequence.intrinsic Intrinsics]]
[def __begin__ [link fusion.sequence.intrinsic.functions.begin `begin`]]
[def __result_of_begin__ [link fusion.sequence.intrinsic.metafunctions.begin `result_of::begin`]]
[def __end__ [link fusion.sequence.intrinsic.functions.end `end`]]
[def __result_of_end__ [link fusion.sequence.intrinsic.metafunctions.end `result_of::end`]]
[def __size__ [link fusion.sequence.intrinsic.functions.size `size`]]
[def __result_of_size__ [link fusion.sequence.intrinsic.metafunctions.size `result_of::size`]]
[def __empty__ [link fusion.sequence.intrinsic.functions.empty `empty`]]
[def __result_of_empty__ [link fusion.sequence.intrinsic.metafunctions.empty `result_of::empty`]]
[def __front__ [link fusion.sequence.intrinsic.functions.front `front`]]
[def __result_of_front__ [link fusion.sequence.intrinsic.metafunctions.front `result_of::front`]]
[def __back__ [link fusion.sequence.intrinsic.functions.back `back`]]
[def __result_of_back__ [link fusion.sequence.intrinsic.metafunctions.back `result_of::back`]]
[def __at__ [link fusion.sequence.intrinsic.functions.at `at`]]
[def __result_of_at__ [link fusion.sequence.intrinsic.metafunctions.at `result_of::at`]]
[def __at_c__ [link fusion.sequence.intrinsic.functions.at_c `at_c`]]
[def __result_of_at_c__ [link fusion.sequence.intrinsic.metafunctions.at_c `result_of::at_c`]]
[def __at_key__ [link fusion.sequence.intrinsic.functions.at_key `at_key`]]
[def __result_of_at_key__ [link fusion.sequence.intrinsic.metafunctions.at_key `result_of::at_key`]]
[def __has_key__ [link fusion.sequence.intrinsic.functions.has_key `has_key`]]
[def __result_of_has_key__ [link fusion.sequence.intrinsic.metafunctions.has_key `result_of::has_key`]]
[def __result_of_value_at__ [link fusion.sequence.intrinsic.metafunctions.value_at `result_of::value_at`]]
[def __result_of_value_at_c__ [link fusion.sequence.intrinsic.metafunctions.value_at_c `result_of::value_at_c`]]
[def __result_of_value_at_key__ [link fusion.sequence.intrinsic.metafunctions.value_at_key `result_of::value_at_key`]]
[def __swap__ [link fusion.sequence.intrinsic.functions.swap `swap`]]
[def __result_of_swap__ [link fusion.sequence.intrinsic.metafunctions.swap `result_of::swap`]]
[def __conversion__ [link fusion.container.conversion.functions Conversion]]
[def __result_of_conversion__ [link fusion.container.conversion.metafunctions Conversion Metafunctions]]
[def __as_vector__ [link fusion.container.conversion.functions.as_vector `as_vector`]]
[def __result_of_as_vector__ [link fusion.container.conversion.metafunctions.as_vector `result_of::as_vector`]]
[def __as_list__ [link fusion.container.conversion.functions.as_list `as_list`]]
[def __result_of_as_list__ [link fusion.container.conversion.metafunctions.as_list `result_of::as_list`]]
[def __as_set__ [link fusion.container.conversion.functions.as_set `as_set`]]
[def __result_of_as_set__ [link fusion.container.conversion.metafunctions.as_set `result_of::as_set`]]
[def __as_map__ [link fusion.container.conversion.functions.as_map `as_map`]]
[def __result_of_as_map__ [link fusion.container.conversion.metafunctions.as_map `result_of::as_map`]]
[def __generation__ [link fusion.container.generation.functions Generation]]
[def __result_of_generation__ [link fusion.container.generation.metafunctions Generation Metafunctions]]
[def __make_vector__ [link fusion.container.generation.functions.make_vector `make_vector`]]
[def __result_of_make_vector__ [link fusion.container.generation.metafunctions.make_vector `result_of::make_vector`]]
[def __vector_tie__ [link fusion.container.generation.functions.vector_tie `vector_tie`]]
[def __map_tie__ [link fusion.container.generation.functions.vector_tie `map_tie`]]
[def __result_of_vector_tie__ [link fusion.container.generation.metafunctions.vector_tie `result_of::vector_tie`]]
[def __make_vector__ [link fusion.container.generation.functions.make_vector `make_vector`]]
[def __result_of_make_vector__ [link fusion.container.generation.metafunctions.make_vector `result_of::make_vector`]]
[def __make_cons__ [link fusion.container.generation.functions.make_cons `make_cons`]]
[def __result_of_make_cons__ [link fusion.container.generation.metafunctions.make_cons `result_of::make_cons`]]
[def __make_list__ [link fusion.container.generation.functions.make_list `make_list`]]
[def __result_of_make_list__ [link fusion.container.generation.metafunctions.make_list `result_of::make_list`]]
[def __make_deque__ [link fusion.container.generation.functions.make_deque `make_deque`]]
[def __result_of_make_deque__ [link fusion.container.generation.metafunctions.make_deque `result_of::make_deque`]]
[def __make_set__ [link fusion.container.generation.functions.make_set `make_set`]]
[def __result_of_make_set__ [link fusion.container.generation.metafunctions.make_set `result_of::make_set`]]
[def __make_map__ [link fusion.container.generation.functions.make_map `make_map`]]
[def __result_of_make_map__ [link fusion.container.generation.metafunctions.make_map `result_of::make_map`]]
[def __list_tie__ [link fusion.container.generation.functions.list_tie `list_tie`]]
[def __result_of_list_tie__ [link fusion.container.generation.metafunctions.list_tie `result_of::list_tie`]]
[def __deque_tie__ [link fusion.container.generation.functions.deque_tie `deque_tie`]]
[def __result_of_deque_tie__ [link fusion.container.generation.metafunctions.deque_tie `result_of::deque_tie`]]
[def __out__ [link fusion.sequence.operator.i_o.out out]]
[def __in__ [link fusion.sequence.operator.i_o.in in]]
[def __eq__ [link fusion.sequence.operator.comparison.equal equal]]
[def __neq__ [link fusion.sequence.operator.comparison.not_equal not equal]]
[def __lt__ [link fusion.sequence.operator.comparison.less_than less than]]
[def __lte__ [link fusion.sequence.operator.comparison.less_than_equal less than equal]]
[def __gt__ [link fusion.sequence.operator.comparison.greater_than greater than]]
[def __gte__ [link fusion.sequence.operator.comparison.greater_than_equal greater than equal]]
[def __algorithm__ [link fusion.algorithm Algorithm]]
[def __algorithms__ [link fusion.algorithm Algorithms]]
[def __copy__ [link fusion.algorithm.auxiliary.functions.copy `copy`]]
[def __result_of_copy__ [link fusion.algorithm.auxiliary.metafunctions.copy `result_of::copy`]]
[def __move__ [link fusion.algorithm.auxiliary.functions.move `move`]]
[def __result_of_move__ [link fusion.algorithm.auxiliary.metafunctions.move `result_of::move`]]
[def __fold__ [link fusion.algorithm.iteration.functions.fold `fold`]]
[def __result_of_fold__ [link fusion.algorithm.iteration.metafunctions.fold `result_of::fold`]]
[def __reverse_fold__ [link fusion.algorithm.iteration.functions.reverse_fold `reverse_fold`]]
[def __result_of_reverse_fold__ [link fusion.algorithm.iteration.metafunctions.reverse_fold `result_of::reverse_fold`]]
[def __iter_fold__ [link fusion.algorithm.iteration.functions.iter_fold `iter_fold`]]
[def __result_of_iter_fold__ [link fusion.algorithm.iteration.metafunctions.iter_fold `result_of::iter_fold`]]
[def __reverse_iter_fold__ [link fusion.algorithm.iteration.functions.reverse_iter_fold `reverse_iter_fold`]]
[def __result_of_reverse_iter_fold__ [link fusion.algorithm.iteration.metafunctions.reverse_iter_fold `result_of::reverse_iter_fold`]]
[def __accumulate__ [link fusion.algorithm.iteration.functions.accumulate `accumulate`]]
[def __result_of_accumulate__ [link fusion.algorithm.iteration.metafunctions.accumulate `result_of::accumulate`]]
[def __for_each__ [link fusion.algorithm.iteration.functions.for_each `for_each`]]
[def __result_of_for_each__ [link fusion.algorithm.iteration.metafunctions.for_each `result_of::for_each`]]
[def __any__ [link fusion.algorithm.query.functions.any `any`]]
[def __result_of_any__ [link fusion.algorithm.query.metafunctions.any `result_of::any`]]
[def __all__ [link fusion.algorithm.query.functions.all `all`]]
[def __result_of_all__ [link fusion.algorithm.query.metafunctions.all `result_of::all`]]
[def __none__ [link fusion.algorithm.query.functions.none `none`]]
[def __result_of_none__ [link fusion.algorithm.query.metafunctions.none `result_of::none`]]
[def __find__ [link fusion.algorithm.query.functions.find `find`]]
[def __result_of_find__ [link fusion.algorithm.query.metafunctions.find `result_of::find`]]
[def __find_if__ [link fusion.algorithm.query.functions.find_if `find_if`]]
[def __result_of_find_if__ [link fusion.algorithm.query.metafunctions.find_if `result_of::find_if`]]
[def __count__ [link fusion.algorithm.query.functions.count `count`]]
[def __result_of_count__ [link fusion.algorithm.query.metafunctions.count `result_of::count`]]
[def __count_if__ [link fusion.algorithm.query.functions.count_if `count_if`]]
[def __result_of_count_if__ [link fusion.algorithm.query.metafunctions.count_if `result_of::count_if`]]
[def __filter__ [link fusion.algorithm.transformation.functions.filter `filter`]]
[def __result_of_filter__ [link fusion.algorithm.transformation.metafunctions.filter `result_of::filter`]]
[def __filter_if__ [link fusion.algorithm.transformation.functions.filter_if `filter_if`]]
[def __result_of_filter_if__ [link fusion.algorithm.transformation.metafunctions.filter_if `result_of::filter_if`]]
[def __transform__ [link fusion.algorithm.transformation.functions.transform `transform`]]
[def __result_of_transform__ [link fusion.algorithm.transformation.metafunctions.transform `result_of::transform`]]
[def __replace__ [link fusion.algorithm.transformation.functions.replace `replace`]]
[def __result_of_replace__ [link fusion.algorithm.transformation.metafunctions.replace `result_of::replace`]]
[def __replace_if__ [link fusion.algorithm.transformation.functions.replace_if `replace_if`]]
[def __result_of_replace_if__ [link fusion.algorithm.transformation.metafunctions.replace_if `result_of::replace_if`]]
[def __remove__ [link fusion.algorithm.transformation.functions.remove `remove`]]
[def __result_of_remove__ [link fusion.algorithm.transformation.metafunctions.remove `result_of::remove`]]
[def __remove_if__ [link fusion.algorithm.transformation.functions.remove_if `remove_if`]]
[def __result_of_remove_if__ [link fusion.algorithm.transformation.metafunctions.remove_if `result_of::remove_if`]]
[def __reverse__ [link fusion.algorithm.transformation.functions.reverse `reverse`]]
[def __result_of_reverse__ [link fusion.algorithm.transformation.metafunctions.reverse `result_of::reverse`]]
[def __clear__ [link fusion.algorithm.transformation.functions.clear `clear`]]
[def __result_of_clear__ [link fusion.algorithm.transformation.metafunctions.clear `result_of::clear`]]
[def __erase__ [link fusion.algorithm.transformation.functions.erase `erase`]]
[def __result_of_erase__ [link fusion.algorithm.transformation.metafunctions.erase `result_of::erase`]]
[def __erase_key__ [link fusion.algorithm.transformation.functions.erase_key `erase_key`]]
[def __result_of_erase_key__ [link fusion.algorithm.transformation.metafunctions.erase_key `result_of::erase_key`]]
[def __insert__ [link fusion.algorithm.transformation.functions.insert `insert`]]
[def __result_of_insert__ [link fusion.algorithm.transformation.metafunctions.insert `result_of::insert`]]
[def __insert_range__ [link fusion.algorithm.transformation.functions.insert_range `insert_range`]]
[def __result_of_insert_range__ [link fusion.algorithm.transformation.metafunctions.insert_range `result_of::insert_range`]]
[def __join__ [link fusion.algorithm.transformation.functions.join `join`]]
[def __result_of_join__ [link fusion.algorithm.transformation.metafunctions.join `result_of::join`]]
[def __zip__ [link fusion.algorithm.transformation.functions.zip `zip`]]
[def __result_of_zip__ [link fusion.algorithm.transformation.metafunctions.zip `result_of::zip`]]
[def __pop_back__ [link fusion.algorithm.transformation.functions.pop_back `pop_back`]]
[def __result_of_pop_back__ [link fusion.algorithm.transformation.metafunctions.pop_back `result_of::pop_back`]]
[def __pop_front__ [link fusion.algorithm.transformation.functions.pop_front `pop_front`]]
[def __result_of_pop_front__ [link fusion.algorithm.transformation.metafunctions.pop_front `result_of::pop_front`]]
[def __push_back__ [link fusion.algorithm.transformation.functions.push_back `push_back`]]
[def __result_of_push_back__ [link fusion.algorithm.transformation.metafunctions.push_back `result_of::push_back`]]
[def __push_front__ [link fusion.algorithm.transformation.functions.push_front `push_front`]]
[def __result_of_push_front__ [link fusion.algorithm.transformation.metafunctions.push_front `result_of::push_front`]]
[def __flatten__ [link fusion.algorithm.transformation.functions.flatten `flatten`]]
[def __result_of_flatten__ [link fusion.algorithm.transformation.metafunctions.flatten `result_of::flatten`]]
[def __tr1_tuple_pair__ [link fusion.tuple.pairs `TR1 and std::pair`]]
[def __tuple_get__ [link fusion.tuple.class_template_tuple.element_access `get`]]
[def __callable_obj__ [link fusion.functional.concepts.callable Callable Object]]
[def __def_callable_obj__ [link fusion.functional.concepts.def_callable Deferred Callable Object]]
[def __reg_callable_obj__ [link fusion.functional.concepts.reg_callable Regular Callable Object]]
[def __poly_func_obj__ [link fusion.functional.concepts.poly Polymorphic Function Object]]
[def __functional_adapters__ [link fusion.functional.adapters functional adapters]]
[def __fused__ [link fusion.functional.adapters.fused `fused`]]
[def __fused_procedure__ [link fusion.functional.adapters.fused_procedure `fused_procedure`]]
[def __fused_function_object__ [link fusion.functional.adapters.fused_function_object `fused_function_object`]]
[def __unfused__ [link fusion.functional.adapters.unfused `unfused`]]
[def __unfused_typed__ [link fusion.functional.adapters.unfused_typed `unfused_typed`]]
[def __invoke__ [link fusion.functional.invocation.functions.invoke `invoke`]]
[def __invoke_procedure__ [link fusion.functional.invocation.functions.invoke_proc `invoke_procedure`]]
[def __invoke_function_object__ [link fusion.functional.invocation.functions.invoke_fobj `invoke_function_object`]]
[def __make_fused__ [link fusion.functional.generation.functions.mk_fused `make_fused`]]
[def __make_fused_procedure__ [link fusion.functional.generation.functions.mk_fused_proc `make_fused_procedure`]]
[def __make_fused_function_object__ [link fusion.functional.generation.functions.mk_fused_fobj `make_fused_function_object`]]
[def __make_unfused__ [link fusion.functional.generation.functions.mk_unfused `make_unfused`]]
[def __result_of_invoke__ [link fusion.functional.invocation.metafunctions.invoke `result_of::invoke`]]
[def __result_of_invoke_procedure__ [link fusion.functional.invocation.metafunctions.invoke_proc `result_of::invoke_procedure`]]
[def __result_of_invoke_function_object__ [link fusion.functional.invocation.metafunctions.invoke_fobj `result_of::invoke_function_object`]]
[def __result_of_make_fused__ [link fusion.functional.generation.metafunctions.mk_fused `result_of::make_fused`]]
[def __result_of_make_fused_procedure__ [link fusion.functional.generation.metafunctions.mk_fused_proc `result_of::make_fused_procedure`]]
[def __result_of_make_fused_function_object__ [link fusion.functional.generation.metafunctions.mk_fused_fobj `result_of::make_fused_function_object`]]
[def __result_of_make_unfused__ [link fusion.functional.generation.metafunctions.mk_unfused `result_of::make_unfused`]]
[def __recursive_inline__ [link fusion.notes.recursive_inlined_functions Recursive Inlined Functions]]
[def __overloaded_functions__ [link fusion.notes.overloaded_functions Overloaded Functions]]
[def __tag_dispatching__ [link fusion.notes.tag_dispatching /tag dispatching/]]
[def __element_conversion__ [link fusion.notes.element_conversion /element conversion/]]
[def __see_element_conversion__ [link fusion.notes.element_conversion /see element conversion/]]
[def __note_ref_wrappers__ [link fusion.notes.reference_wrappers `Reference Wrappers`]]
[def __quick_start__ [link fusion.quick_start Quick Start]]
[def __organization__ [link fusion.organization Organization]]
[def __extension__ [link fusion.extension Extension]]
[def __sequence_facade__ [link fusion.extension.sequence_facade `sequence_facade`]]
[def __iterator_facade__ [link fusion.extension.iterator_facade `iterator_facade`]]
[def __adt_attribute_proxy__ [link fusion.notes.adt_attribute_proxy `adt_attribute_proxy`]]
[def __window_function__ [@http://en.wikipedia.org/wiki/Window_function Window Function]]
[include preface.qbk]
[include introduction.qbk]
[include quick_start.qbk]
[include organization.qbk]
[include support.qbk]
[include iterator.qbk]
[include sequence.qbk]
[include container.qbk]
[include view.qbk]
[include adapted.qbk]
[include algorithm.qbk]
[include tuple.qbk]
[include extension.qbk]
[include functional.qbk]
[include notes.qbk]
[include changelog.qbk]
[include acknowledgements.qbk]
[include references.qbk]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,287 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter&#160;1.&#160;Fusion 2.2</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Fusion 2.2">
<link rel="next" href="fusion/preface.html" title="Preface">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="fusion/preface.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="fusion"></a>Chapter&#160;1.&#160;Fusion 2.2</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Joel</span> <span class="surname">de Guzman</span>
</h3></div></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Dan</span> <span class="surname">Marsden</span>
</h3></div></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Tobias</span> <span class="surname">Schwinger</span>
</h3></div></div>
<div><p class="copyright">Copyright &#169; 2001-2006, 2011, 2012 Joel de Guzman,
Dan Marsden, Tobias Schwinger</p></div>
<div><div class="legalnotice">
<a name="fusion.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="fusion/preface.html">Preface</a></span></dt>
<dt><span class="section"><a href="fusion/introduction.html">Introduction</a></span></dt>
<dt><span class="section"><a href="fusion/quick_start.html">Quick Start</a></span></dt>
<dt><span class="section"><a href="fusion/organization.html">Organization</a></span></dt>
<dt><span class="section"><a href="fusion/support.html">Support</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/support/is_sequence.html">is_sequence</a></span></dt>
<dt><span class="section"><a href="fusion/support/is_view.html">is_view</a></span></dt>
<dt><span class="section"><a href="fusion/support/tag_of.html">tag_of</a></span></dt>
<dt><span class="section"><a href="fusion/support/category_of.html">category_of</a></span></dt>
<dt><span class="section"><a href="fusion/support/deduce.html">deduce</a></span></dt>
<dt><span class="section"><a href="fusion/support/deduce_sequence.html">deduce_sequence</a></span></dt>
<dt><span class="section"><a href="fusion/support/pair.html">pair</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/iterator.html">Iterator</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/iterator/concepts.html">Concepts</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/iterator/concepts/forward_iterator.html">Forward
Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/bidirectional_iterator.html">Bidirectional
Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/random_access_iterator.html">Random
Access Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/associative_iterator.html">Associative
Iterator</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/concepts/unbounded_iterator.html">Unbounded
Iterator</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/iterator/functions.html">Functions</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/iterator/functions/deref.html">deref</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/next.html">next</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/prior.html">prior</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/distance.html">distance</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/advance.html">advance</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/advance_c.html">advance_c</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/functions/deref_data.html">deref_data</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/iterator/operator.html">Operator</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/iterator/operator/operator_unary_star.html">Operator
*</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/operator/operator_equality.html">Operator
==</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/operator/operator_inequality.html">Operator
!=</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/iterator/metafunctions.html">Metafunctions</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/iterator/metafunctions/value_of.html">value_of</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/deref.html">deref</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/next.html">next</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/prior.html">prior</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/equal_to.html">equal_to</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/distance.html">distance</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/advance.html">advance</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/advance_c.html">advance_c</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/key_of.html">key_of</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/value_of_data.html">value_of_data</a></span></dt>
<dt><span class="section"><a href="fusion/iterator/metafunctions/deref_data.html">deref_data</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="fusion/sequence.html">Sequence</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/sequence/concepts.html">Concepts</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/sequence/concepts/forward_sequence.html">Forward
Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/bidirectional_sequence.html">Bidirectional
Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/random_access_sequence.html">Random
Access Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/associative_sequence.html">Associative
Sequence</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/concepts/unbounded_sequence.html">Unbounded
Sequence</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/sequence/intrinsic.html">Intrinsic</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/sequence/intrinsic/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/intrinsic/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/sequence/operator.html">Operator</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/sequence/operator/i_o.html">I/O</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/operator/comparison.html">Comparison</a></span></dt>
<dt><span class="section"><a href="fusion/sequence/operator/hashing.html">Hashing</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="fusion/container.html">Container</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/container/vector.html">vector</a></span></dt>
<dt><span class="section"><a href="fusion/container/cons.html">cons</a></span></dt>
<dt><span class="section"><a href="fusion/container/list.html">list</a></span></dt>
<dt><span class="section"><a href="fusion/container/deque.html">deque</a></span></dt>
<dt><span class="section"><a href="fusion/container/front_extended_deque.html">front_extended_deque</a></span></dt>
<dt><span class="section"><a href="fusion/container/back_extended_deque.html">back_extended_deque</a></span></dt>
<dt><span class="section"><a href="fusion/container/set.html">set</a></span></dt>
<dt><span class="section"><a href="fusion/container/map.html">map</a></span></dt>
<dt><span class="section"><a href="fusion/container/generation.html">Generation</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/container/generation/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/container/generation/metafunctions.html">MetaFunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/container/conversion.html">Conversion</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/container/conversion/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/container/conversion/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="fusion/view.html">View</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/view/single_view.html">single_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/filter_view.html">filter_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/iterator_range.html">iterator_range</a></span></dt>
<dt><span class="section"><a href="fusion/view/joint_view.html">joint_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/zip_view.html">zip_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/transform_view.html">transform_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/reverse_view.html">reverse_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/nview.html">nview</a></span></dt>
<dt><span class="section"><a href="fusion/view/repetitive_view.html">repetitive_view</a></span></dt>
<dt><span class="section"><a href="fusion/view/flatten_view.html">flatten_view</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/adapted.html">Adapted</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/adapted/array.html">Array</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/std__pair.html">std::pair</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/std__tuple.html">std::tuple</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/mpl_sequence.html">mpl sequence</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/boost__array.html">boost::array</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/boost__tuple.html">boost::tuple</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_struct.html">BOOST_FUSION_ADAPT_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_tpl_struct.html">BOOST_FUSION_ADAPT_TPL_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_struct_named.html">BOOST_FUSION_ADAPT_STRUCT_NAMED</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_assoc.html">BOOST_FUSION_ADAPT_ASSOC_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_assoc_tpl_struct.html">BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_assoc_struct_named.html">BOOST_FUSION_ADAPT_ASSOC_STRUCT_NAMED</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_adt.html">BOOST_FUSION_ADAPT_ADT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_tpl_adt.html">BOOST_FUSION_ADAPT_TPL_ADT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_assoc_adt.html">BOOST_FUSION_ADAPT_ASSOC_ADT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/adapt_assoc_tpl_adt.html">BOOST_FUSION_ADAPT_ASSOC_TPL_ADT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_struct.html">BOOST_FUSION_DEFINE_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_tpl_struct.html">BOOST_FUSION_DEFINE_TPL_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_struct_inline.html">BOOST_FUSION_DEFINE_STRUCT_INLINE</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_tpl_struct_inline.html">BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_assoc_struct.html">BOOST_FUSION_DEFINE_ASSOC_STRUCT</a></span></dt>
<dt><span class="section"><a href="fusion/adapted/define_assoc_tpl_struct.html">BOOST_FUSION_DEFINE_ASSOC_TPL_STRUCT</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/algorithm.html">Algorithm</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/auxiliary.html">Auxiliary</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/auxiliary/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/algorithm/auxiliary/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/algorithm/iteration.html">Iteration</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/iteration/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/algorithm/iteration/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/algorithm/query.html">Query</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/query/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/algorithm/query/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/algorithm/transformation.html">Transformation</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/transformation/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/algorithm/transformation/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="fusion/tuple.html">Tuple</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple.html">Class template tuple</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple/construction.html">Construction</a></span></dt>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple/tuple_creation_functions.html">Tuple
creation functions</a></span></dt>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple/tuple_helper_classes.html">Tuple
helper classes</a></span></dt>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple/element_access.html">Element
access</a></span></dt>
<dt><span class="section"><a href="fusion/tuple/class_template_tuple/relational_operators.html">Relational
operators</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/tuple/pairs.html">Pairs</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/extension.html">Extension</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/extension/ext_full.html">The Full Extension Mechanism</a></span></dt>
<dt><span class="section"><a href="fusion/extension/sequence_facade.html">Sequence Facade</a></span></dt>
<dt><span class="section"><a href="fusion/extension/iterator_facade.html">Iterator Facade</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/functional.html">Functional</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/functional/concepts.html">Concepts</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/functional/concepts/callable.html">Callable Object</a></span></dt>
<dt><span class="section"><a href="fusion/functional/concepts/reg_callable.html">Regular Callable
Object</a></span></dt>
<dt><span class="section"><a href="fusion/functional/concepts/def_callable.html">Deferred Callable
Object</a></span></dt>
<dt><span class="section"><a href="fusion/functional/concepts/poly.html">Polymorphic Function
Object</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/functional/invocation.html">Invocation</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/functional/invocation/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/functional/invocation/metafunctions.html">Metafunctions</a></span></dt>
<dt><span class="section"><a href="fusion/functional/invocation/limits.html">Limits</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/functional/adapters.html">Adapters</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/functional/adapters/fused.html">fused</a></span></dt>
<dt><span class="section"><a href="fusion/functional/adapters/fused_procedure.html">fused_procedure</a></span></dt>
<dt><span class="section"><a href="fusion/functional/adapters/fused_function_object.html">fused_function_object</a></span></dt>
<dt><span class="section"><a href="fusion/functional/adapters/unfused.html">unfused</a></span></dt>
<dt><span class="section"><a href="fusion/functional/adapters/unfused_typed.html">unfused_typed</a></span></dt>
<dt><span class="section"><a href="fusion/functional/adapters/limits.html">Limits</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/functional/generation.html">Generation</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/functional/generation/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/functional/generation/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
</dl></dd>
<dt><span class="section"><a href="fusion/notes.html">Notes</a></span></dt>
<dt><span class="section"><a href="fusion/change_log.html">Change log</a></span></dt>
<dt><span class="section"><a href="fusion/acknowledgements.html">Acknowledgements</a></span></dt>
<dt><span class="section"><a href="fusion/references.html">References</a></span></dt>
</dl>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: June 25, 2015 at 13:41:27 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav"><a accesskey="n" href="fusion/preface.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
</body>
</html>

View File

@ -1,91 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Introduction]
An advantage other languages such as Python and Lisp/ Scheme, ML and
Haskell, etc., over C++ is the ability to have heterogeneous containers
that can hold arbitrary element types. All the containers in the standard
library can only hold a specific type. A `vector<int>` can only hold
`int`s. A `list<X>` can only hold elements of type `X`, and so on.
True, you can use inheritance to make the containers hold different types,
related through subclassing. However, you have to hold the objects through
a pointer or smart reference of some sort. Doing this, you'll have to rely
on virtual functions to provide polymorphic behavior since the actual type
is erased as soon as you store a pointer to a derived class to a pointer to
its base. The held objects must be related: you cannot hold objects of
unrelated types such as `char`, `int`, `class X`, `float`, etc. Oh sure you
can use something like __boost_any__ to hold arbitrary types, but then you
pay more in terms of runtime costs and due to the fact that you practically
erased all type information, you'll have to perform dangerous casts to get
back the original type.
The __tuple__ library written by __jaakko_jarvi__ provides heterogeneous
containers in C++. The `tuple` is a basic data structure that can hold
heterogeneous types. It's a good first step, but it's not complete. What's
missing are the algorithms. It's nice that we can store and retrieve data
to and from tuples, pass them around as arguments and return types. As it
is, the __tuple__ facility is already very useful. Yet, as soon as you use
it more often, usage patterns emerge. Eventually, you collect these
patterns into algorithm libraries.
Hmmm, kinda reminds us of STL right? Right! Can you imagine how it would be
like if you used STL without the algorithms? Everyone will have to reinvent
their own /algorithm/ wheels.
Fusion is a library and a framework similar to both __stl__ and the boost
__mpl__. The structure is modeled after __mpl__, which is modeled
after __stl__. It is named "fusion" because the library is reminiscent of
the "fusion" of compile time meta-programming with runtime programming. The
library inherently has some interesting flavors and characteristics of both
__mpl__ and __stl__. It lives in the twilight zone between compile time
meta-programming and run time programming. __stl__ containers work on
values. MPL containers work on types. Fusion containers work on both types
and values.
Unlike __mpl__, Fusion algorithms are lazy and non sequence-type
preserving. What does that mean? It means that when you operate on a
sequence through a Fusion algorithm that returns a sequence, the sequence
returned may not be of the same class as the original. This is by design.
Runtime efficiency is given a high priority. Like __mpl__, and unlike
__stl__, fusion algorithms are functional in nature such that algorithms
are non mutating (no side effects). However, due to the high cost of
returning full sequences such as vectors and lists, /Views/ are returned
from Fusion algorithms instead. For example, the __transform__ algorithm
does not actually return a transformed version of the original sequence.
__transform__ returns a __transform_view__. This view holds a reference to
the original sequence plus the transform function. Iteration over the
__transform_view__ will apply the transform function over the sequence
elements on demand. This /lazy/ evaluation scheme allows us to chain as
many algorithms as we want without incurring a high runtime penalty.
The /lazy/ evaluation scheme where algorithms return views allows
operations such as __push_back__ to be totally generic. In Fusion,
__push_back__ is actually a generic algorithm that works on all sequences.
Given an input sequence `s` and a value `x`, Fusion's __push_back__
algorithm simply returns a __joint_view__: a view that holds a reference to
the original sequence `s` and the value `x`. Functions that were once
sequence specific and need to be implemented N times over N different
sequences are now implemented only once.
Fusion provides full round compatibility with __mpl__. Fusion sequences are
fully conforming __mpl__ sequences and __mpl__ sequences are fully compatible
with Fusion. You can work with Fusion sequences on __mpl__ if you wish to work
solely on types [footnote Choose __mpl__ over fusion when doing pure type
calculations. Once the static type calculation is finished, you can instantiate
a fusion sequence (see __conversion__) for the runtime part.]. In __mpl__,
Fusion sequences follow __mpl__'s sequence-type preserving semantics (i.e.
algorithms preserve the original sequence type. e.g. transforming a vector
returns a vector). You can also convert from an __mpl__ sequence to a Fusion
sequence. For example, there are times when it is convenient to work solely on
__mpl__ using pure __mpl__ sequences, then, convert them to Fusion sequences as
a final step before actual instantiation of real runtime objects with data. You
have the best of both worlds.
[endsect]

File diff suppressed because it is too large Load Diff

View File

@ -1,231 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 Dan Marsden
Copyright (C) 2010 Christopher Schmidt
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)
===============================================================================/]
[section Notes]
[heading Recursive Inlined Functions]
An interesting peculiarity of functions like __at__ when applied to a
__forward_sequence__ like __list__ is that what could have been linear
runtime complexity effectively becomes constant O(1) due to compiler
optimization of C++ inlined functions, however deeply recursive (up to a
certain compiler limit of course). Compile time complexity remains linear.
[heading Overloaded Functions]
Associative sequences use function overloading to implement membership
testing and type associated key lookup. This amounts to constant runtime
and amortized constant compile time complexities. There is an overloaded
function, `f(k)`, for each key /type/ `k`. The compiler chooses the
appropriate function given a key, `k`.
[heading Tag Dispatching]
Tag dispatching is a generic programming technique for selecting template
specializations. There are typically 3 components involved in the tag
dispatching mechanism:
# A type for which an appropriate template specialization is required
# A metafunction that associates the type with a tag type
# A template that is specialized for the tag type
For example, the fusion `result_of::begin` metafunction is implemented
as follows:
template <typename Sequence>
struct begin
{
typedef typename
result_of::begin_impl<typename traits::tag_of<Sequence>::type>::
template apply<Sequence>::type
type;
};
In the case:
# `Sequence` is the type for which a suitable implementation of
`result_of::begin_impl` is required
# `traits::tag_of` is the metafunction that associates `Sequence`
with an appropriate tag
# `result_of::begin_impl` is the template which is specialized to provide
an implementation for each tag type
[heading Extensibility]
Unlike __mpl__, there is no extensible sequence concept in fusion. This does
not mean that Fusion sequences are not extensible. In fact, all Fusion
sequences are inherently extensible. It is just that the manner of sequence
extension in Fusion is different from both __stl__ and __mpl__ on account of
the lazy nature of fusion __algorithms__. __stl__ containers extend
themselves in place though member functions such as __push_back__ and
__insert__. __mpl__ sequences, on the other hand, are extended through
"intrinsic" functions that actually return whole sequences. __mpl__ is
purely functional and can not have side effects. For example, __mpl__'s
`push_back` does not actually mutate an `mpl::vector`. It can't do that.
Instead, it returns an extended `mpl::vector`.
Like __mpl__, Fusion too is purely functional and can not have side
effects. With runtime efficiency in mind, Fusion sequences are extended
through generic functions that return __views__. __views__ are sequences
that do not actually contain data, but instead impart an alternative
presentation over the data from one or more underlying sequences. __views__
are proxies. They provide an efficient yet purely functional way to work on
potentially expensive sequence operations. For example, given a __vector__,
Fusion's __push_back__ returns a __joint_view__, instead of an actual
extended __vector__. A __joint_view__ holds a reference to the original
sequence plus the appended data --making it very cheap to pass around.
[heading Element Conversion]
Functions that take in elemental values to form sequences (e.g.
__make_list__) convert their arguments to something suitable to be stored
as a sequence element. In general, the element types are stored as plain
values. Example:
__make_list__(1, 'x')
returns a __list__`<int, char>`.
There are a few exceptions, however.
[*Arrays:]
Array arguments are deduced to reference to const types. For example
[footnote Note that the type of a string literal is an array of const
characters, not `const char*`. To get __make_list__ to create a __list__
with an element of a non-const array type one must use the `ref` wrapper
(see __note_ref_wrappers__).]:
__make_list__("Donald", "Daisy")
creates a __list__ of type
__list__<const char (&)[7], const char (&)[6]>
[*Function pointers:]
Function pointers are deduced to the plain non-reference type (i.e. to
plain function pointer). Example:
void f(int i);
...
__make_list__(&f);
creates a __list__ of type
__list__<void (*)(int)>
[heading Reference Wrappers]
Fusion's generation functions (e.g. __make_list__) by default stores the
element types as plain non-reference types. Example:
void foo(const A& a, B& b) {
...
__make_list__(a, b)
creates a __list__ of type
__list__<A, B>
Sometimes the plain non-reference type is not desired. You can use
`boost::ref` and `boost::cref` to store references or const references
(respectively) instead. The mechanism does not compromise const correctness
since a const object wrapped with ref results in a tuple element with const
reference type (see the fifth code line below). Examples:
For example:
A a; B b; const A ca = a;
__make_list__(cref(a), b); // creates list<const A&, B>
__make_list__(ref(a), b); // creates list<A&, B>
__make_list__(ref(a), cref(b)); // creates list<A&, const B&>
__make_list__(cref(ca)); // creates list<const A&>
__make_list__(ref(ca)); // creates list<const A&>
See __boost_ref__ for details.
Since C++11, the standard reference wrappers (`std::ref` and `std::cref`) work as well.
[heading adt_attribute_proxy]
To adapt arbitrary data types that do not allow direct access to their members,
but allow indirect access via expressions (such as invocations of get- and
set-methods), fusion's [^BOOST\_FUSION\_ADAPT\_['xxx]ADT['xxx]]-family (e.g.
__adapt_adt__) may be used.
To bypass the restriction of not having actual lvalues that
represent the elements of the fusion sequence, but rather a sequence of paired
expressions that access the elements, the actual return type of fusion's
intrinsic sequence access functions (__at__, __at_c__, __at_key__, __deref__,
and __deref_data__) is a proxy type, an instance of
`adt_attribute_proxy`, that encapsulates these expressions.
`adt_attribute_proxy` is defined in the namespace `boost::fusion::extension` and
has three template arguments:
namespace boost { namespace fusion { namespace extension
{
template<
typename Type
, int Index
, bool Const
>
struct adt_attribute_proxy;
}}}
When adapting a class type, `adt_attribute_proxy` is specialized for every
element of the adapted sequence, with `Type` being the class type that is
adapted, `Index` the 0-based indices of the elements, and `Const` both `true`
and `false`. The return type of fusion's intrinsic sequence access functions
for the ['N]th element of an adapted class type `type_name` is
[^adt_attribute_proxy<type_name, ['N], ['Const]>], with [^['Const]] being `true`
for constant instances of `type_name` and `false` for non-constant ones.
[variablelist Notation
[[`type_name`]
[The type to be adapted, with M attributes]]
[[`inst`]
[Object of type `type_name`]]
[[`const_inst`]
[Object of type `type_name const`]]
[[[^(attribute_type['N], attribute_const_type['N], get_expr['N], set_expr['N])]]
[Attribute descriptor of the ['N]th attribute of `type_name` as passed to the adaption macro, 0\u2264['N]<M]]
[[[^proxy_type['N]]]
[[^adt_attribute_proxy<type_name, ['N], `false`>] with ['N] being an integral constant, 0\u2264['N]<M]]
[[[^const_proxy_type['N]]]
[[^adt_attribute_proxy<type_name, ['N], `true`>] with ['N] being an integral constant, 0\u2264['N]<M]]
[[[^proxy['N]]]
[Object of type [^proxy_type['N]]]]
[[[^const_proxy['N]]]
[Object of type [^const_proxy_type['N]]]]
]
[*Expression Semantics]
[table
[[Expression] [Semantics]]
[[[^proxy_type['N](inst)]] [Creates an instance of [^proxy_type['N]] with underlying object `inst`]]
[[[^const_proxy_type['N](const_inst)]] [Creates an instance of [^const_proxy_type['N]] with underlying object `const_inst`]]
[[[^proxy_type['N]::type]] [Another name for [^attribute_type['N]]]]
[[[^const_proxy_type['N]::type]] [Another name for [^const_attribute_type['N]]]]
[[[^proxy['N]=t]] [Invokes [^set_expr['N]], with `t` being an arbitrary object. [^set_expr['N]] may access the variables named `obj` of type `type_name&`, which represent the corresponding instance of `type_name`, and `val` of an arbitrary const-qualified reference template type parameter `Val`, which represents `t`.]]
[[[^proxy['N].get()]] [Invokes [^get_expr['N]] and forwards its return value. [^get_expr['N]] may access the variable named `obj` of type `type_name&` which represents the underlying instance of `type_name`. [^attribute_type['N]] may specify the type that [^get_expr['N]] denotes to.]]
[[[^const_proxy['N].get()]] [Invokes [^get_expr['N]] and forwards its return value. [^get_expr['N]] may access the variable named `obj` of type `type_name const&` which represents the underlying instance of `type_name`. [^attribute_const_type['N]] may specify the type that [^get_expr['N]] denotes to.]]
]
Additionally, [^proxy_type['N]] and [^const_proxy_type['N]] are copy
constructible, copy assignable and implicitly convertible to
[^proxy_type['N]::type] or [^const_proxy_type['N]::type].
[tip To avoid the pitfalls of the proxy type, an arbitrary class type may also
be adapted directly using fusion's [link fusion.extension intrinsic extension
mechanism].]
[endsect]

View File

@ -1,97 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Organization]
The library is organized into layers of modules, with each module addressing a particular
area of responsibility. A module may not depend on modules in higher layers.
The library is organized in three layers:
[heading Layers]
[:[$images/fusion_org.png]]
The entire library is found in the `"boost/fusion"` directory. Modules are
organized in directories. Each module has its own header file placed in
the same directory with the actual module-directory. For example, there
exists `"boost/fusion/support.hpp"` in the same directory as
"boost/fusion/support". Everything, except those found inside "detail"
directories, is public.
There is also a `"boost/fusion/include/"` directory that contains all the
headers to all the components and modules. If you are unsure where to
find a specific component or module, or don't want to fuss with
hierarchy and nesting, use this.
The library is header-only. There is no need to build object files to
link against.
[heading Directory]
* tuple
* algorithm
* auxiliary
* iteration
* query
* transformation
* adapted
* adt
* array
* boost::array
* boost::tuple
* mpl
* std_pair
* std_tuple
* struct
* view
* filter_view
* flatten_view
* iterator_range
* joint_view
* nview
* repetitive_view
* reverse_view
* single_view
* transform_view
* zip_view
* container
* deque
* list
* map
* set
* vector
* generation
* mpl
* functional
* adapter
* generation
* invocation
* sequence
* comparison
* intrinsic
* io
* iterator
* support
[heading Example]
If, for example, you want to use `list`, depending on the granularity that
you desire, you may do so by including one of
#include <boost/fusion/container.hpp>
#include <boost/fusion/include/container.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/include/list.hpp>
The first includes all containers The second includes only `list`
[footnote Modules may contain smaller components. Header file
information for each component will be provided as part of the
component's documentation.].
[endsect]

View File

@ -1,68 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Preface]
[:['["Algorithms + Data Structures = Programs.]]]
[:*--Niklaus Wirth*]
[heading Description]
Fusion is a library for working with heterogeneous collections of data,
commonly referred to as tuples. A set of containers (vector, list, set and map)
is provided, along with views that provide a transformed presentation
of their underlying data. Collectively the containers and views are referred to
as sequences, and Fusion has a suite of algorithms that operate upon the
various sequence types, using an iterator concept that binds everything
together.
The architecture is modeled after __mpl__ which in turn is modeled after
__stl__. It is named "fusion" because the library is a "fusion" of compile
time metaprogramming with runtime programming.
[heading Motivation]
Tuples are powerful beasts. After having developed two significant projects
(__spirit__ and __phoenix__) that relied heavily metaprogramming, it
became apparent that tuples are a powerful means to simplify otherwise tricky
tasks; especially those that require a combination of metaprogramming and
manipulation of heterogeneous data types with values. While __mpl__ is an
extremely powerful metaprogramming tool, __mpl__ focuses on type
manipulation only. Ultimately, you'll have to map these types to real
values to make them useful in the runtime world where all the real action
takes place.
As __spirit__ and __phoenix__ evolved, patterns and idioms related to tuple
manipulation emerged. Soon, it became clear that those patterns and idioms
were best assembled in a tuples algorithms library. __david_abrahams__
outlined such a scheme in 2002. At that time, it just so happened that
__spirit__ and __phoenix__ had an adhoc collection of tuple manipulation
and traversal routines. It was an instant /AHA!/ moment.
[heading How to use this manual]
Some icons are used to mark certain topics indicative of their relevance.
These icons precede some text to indicate:
[note Information provided is auxiliary but will give the reader a deeper
insight into a specific topic. May be skipped.]
[important Information provided is of utmost importance.]
[caution A mild warning.]
[tip A potentially useful and helpful piece of information.]
This documentation is automatically generated by Boost QuickBook documentation
tool. QuickBook can be found in the __boost_tools__.
[heading Support]
Please direct all questions to Spirit's mailing list. You can subscribe to the
__spirit_list__. The mailing list has a searchable archive. Here is a link to
the archives: __list_archive__.
[endsect]

View File

@ -1,169 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Quick Start]
I assume the reader is already familiar with tuples (__tuple__) and its
ancestor `std::pair`. The tuple is a generalization of `std::pair` for
multiple heterogeneous elements (triples, quadruples, etc.). The tuple is
more or less a synonym for fusion's `__vector__`.
For starters, we shall include all of Fusion's __sequence__(s) [footnote There
are finer grained header files available if you wish to have more control
over which components to include (see section __organization__ for
details).]:
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/include/sequence.hpp>
Let's begin with a `__vector__` [footnote Unless otherwise noted, components are
in namespace `boost::fusion`. For the sake of simplicity, code in this
quick start implies `using` directives for the fusion components we will be
using.]:
__vector__<int, char, std::string> stuff(1, 'x', "howdy");
int i = __at_c__<0>(stuff);
char ch = __at_c__<1>(stuff);
std::string s = __at_c__<2>(stuff);
Just replace `tuple` for `__vector__` and `get` for `__at_c__` and this is exactly
like __tuple__. Actually, either names can be used interchangeably. Yet,
the similarity ends there. You can do a lot more with Fusion `__vector__` or
`tuple`. Let's see some examples.
[heading Print the vector as XML]
First, let's include the algorithms:
#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/include/algorithm.hpp>
Now, let's write a function object that prints XML of the form <type>data</type>
for each member in the tuple.
struct print_xml
{
template <typename T>
void operator()(T const& x) const
{
std::cout
<< '<' << typeid(x).name() << '>'
<< x
<< "</" << typeid(x).name() << '>'
;
}
};
Now, finally:
__for_each__(stuff, print_xml());
That's it! `__for_each__` is a fusion algorithm. It is a generic algorithm
similar to __stl__'s. It iterates over the sequence and calls a user
supplied function. In our case, it calls `print_xml`'s `operator()` for
each element in `stuff`.
[caution The result of `typeid(x).name()` is platform specific. The code
here is just for exposition. Of course you already know that :-)]
`__for_each__` is generic. With `print_xml`, you can use it to print just about
any Fusion __sequence__.
[heading Print only pointers]
Let's get a little cleverer. Say we wish to write a /generic/ function
that takes in an arbitrary sequence and XML prints only those elements
which are pointers. Ah, easy. First, let's include the `is_pointer` boost
type trait:
#include <boost/type_traits/is_pointer.hpp>
Then, simply:
template <typename Sequence>
void xml_print_pointers(Sequence const& seq)
{
__for_each__(__filter_if__<boost::is_pointer<_> >(seq), print_xml());
}
`__filter_if__` is another Fusion algorithm. It returns a __filter_view__,
a conforming Fusion sequence. This view reflects only those elements that
pass the given predicate. In this case, the predicate is
`boost::is_pointer<_>`. This "filtered view" is then passed to the
__for_each__ algorithm, which then prints the "filtered view" as XML.
Easy, right?
[heading Associative tuples]
Ok, moving on...
Apart from `__vector__`, fusion has a couple of other sequence types to choose
from. Each sequence has its own characteristics. We have `__list__`, `__set__`,
`__map__`, plus a multitude of `views` that provide various ways to present the
sequences.
Fusion's `__map__` associate types with elements. It can be used as a cleverer
replacement of the `struct`. Example:
namespace fields
{
struct name;
struct age;
}
typedef __map__<
__fusion_pair__<fields::name, std::string>
, __fusion_pair__<fields::age, int> >
person;
`__map__` is an associative sequence. Its elements are Fusion pairs which differ
somewhat from `std::pair`. Fusion pairs only contain one member, with the type of
their second template parameter. The first type parameter of the pair is used as an
index to the associated element in the sequence. For example, given a `a_person`
of type, `person`, you can do:
using namespace fields;
std::string person_name = __at_key__<name>(a_person);
int person_age = __at_key__<age>(a_person);
Why go through all this trouble, you say? Well, for one, unlike the
`struct`, we are dealing with a generic data structure. There are a
multitude of facilities available at your disposal provided out of the box
with fusion or written by others. With these facilities, introspection
comes for free, for example. We can write one serialization function (well,
two, if you consider loading and saving) that will work for all your fusion
`__map__`s. Example:
struct saver
{
template <typename Pair>
void operator()(Pair const& data) const
{
some_archive << data.second;
}
};
template <typename Stuff>
void save(Stuff const& stuff)
{
__for_each__(stuff, saver());
}
The `save` function is generic and will work for all types of `stuff`
regardless if it is a `person`, a `dog` or a whole `alternate_universe`.
[heading Tip of the Iceberg]
And... we've barely scratched the surface! You can compose and expand the
data structures, remove elements from the structures, find specific data
types, query the elements, filter out types for inspection, transform data
structures, etc. What you've seen is just the tip of the iceberg.
[endsect]

View File

@ -1,28 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 Dan Marsden
Copyright (C) 2018 Kohei Takahashi
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)
===============================================================================/]
[section References]
# [@http://www.boost.org/libs/iterator/doc/new-iter-concepts.html New Iterator Concepts],
David Abrahams, Jeremy Siek, Thomas Witt, 2004-11-01.
# [@http://www.boost.org/libs/tuple The Boost Tuple Library],
Jaakko Jarvi, 2001.
# [@http://www.boost.org/libs/spirit Spirit Parser Library],
Joel de Guzman, 2001-2006.
# [@http://www.boost.org/libs/mpl The Boost MPL Library],
Aleksey Gurtovoy and David Abrahams, 2002-2004.
# [@http://www.boost.org/libs/array The Boost Array Library],
Nicolai Josuttis, 2002-2004.
# [@http://www.boost.org/libs/core/ref.html Boost.Core / Ref utility],
Jaakko Jarvi, Peter Dimov, Douglas Gregor, Dave Abrahams, 1999-2002.
# [@http://www.boost.org/libs/hana The Boost Hana Library],
Louis Dionne, 2017.
[endsect]

File diff suppressed because it is too large Load Diff

View File

@ -1,427 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Support]
A couple of classes and metafunctions provide basic support for Fusion.
[section is_sequence]
[heading Description]
Metafunction that evaluates to `mpl::true_` if a certain type `T` is a
conforming Fusion __sequence__, `mpl::false_` otherwise. This may be
specialized to accommodate clients which provide Fusion conforming sequences.
[heading Synopsis]
namespace traits
{
template <typename T>
struct is_sequence
{
typedef __unspecified__ type;
};
}
[heading Parameters]
[table
[[Parameter] [Requirement] [Description]]
[[`T`] [Any type] [The type to query.]]
]
[heading Expression Semantics]
typedef traits::is_sequence<T>::type c;
[*Return type]: An __mpl_boolean_constant__.
[*Semantics]: Metafunction that evaluates to `mpl::true_` if a certain type
`T` is a conforming Fusion sequence, `mpl::false_` otherwise.
[heading Header]
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/include/is_sequence.hpp>
[heading Example]
BOOST_MPL_ASSERT_NOT(( traits::is_sequence< std::vector<int> > ));
BOOST_MPL_ASSERT_NOT(( is_sequence< int > ));
BOOST_MPL_ASSERT(( traits::is_sequence<__list__<> > ));
BOOST_MPL_ASSERT(( traits::is_sequence<__list__<int> > ));
BOOST_MPL_ASSERT(( traits::is_sequence<__vector__<> > ));
BOOST_MPL_ASSERT(( traits::is_sequence<__vector__<int> > ));
[endsect]
[section is_view]
[heading Description]
Metafunction that evaluates to `mpl::true_` if a certain type `T` is a
conforming Fusion __view__, `mpl::false_` otherwise. A view is a
specialized sequence that does not actually contain data. Views hold
sequences which may be other views. In general, views are held by other
views by value, while non-views are held by other views by reference. `is_view`
may be specialized to accommodate clients providing Fusion conforming views.
[heading Synopsis]
namespace traits
{
template <typename T>
struct is_view
{
typedef __unspecified__ type;
};
}
[heading Parameters]
[table
[[Parameter] [Requirement] [Description]]
[[`T`] [Any type] [The type to query.]]
]
[heading Expression Semantics]
typedef traits::is_view<T>::type c;
[*Return type]: An __mpl_boolean_constant__.
[*Semantics]: Metafunction that evaluates to `mpl::true_` if a certain type
`T` is a conforming Fusion view, `mpl::false_` otherwise.
[heading Header]
#include <boost/fusion/support/is_view.hpp>
#include <boost/fusion/include/is_view.hpp>
[heading Example]
BOOST_MPL_ASSERT_NOT(( traits::is_view<std::vector<int> > ));
BOOST_MPL_ASSERT_NOT(( traits::is_view<int> ));
using boost::mpl::_
using boost::is_pointer;
typedef __vector__<int*, char, long*, bool, double> vector_type;
typedef __filter_view__<vector_type, is_pointer<_> > filter_view_type;
BOOST_MPL_ASSERT(( traits::is_view<filter_view_type> ));
[endsect]
[section tag_of]
[heading Description]
All conforming Fusion sequences and iterators have an associated tag type. The
purpose of the tag is to enable __tag_dispatching__ from __intrinsic__
functions to implementations appropriate for the type.
This metafunction may be specialized to accommodate clients providing Fusion
conforming sequences.
[heading Synopsis]
namespace traits
{
template<typename Sequence>
struct tag_of
{
typedef __unspecified__ type;
};
}
[heading Parameters]
[table
[[Parameter] [Requirement] [Description]]
[[`T`] [Any type] [The type to query.]]
]
[heading Expression Semantics]
typedef traits::tag_of<T>::type tag;
[*Return type]: Any type.
[*Semantics]: Returns the tag type associated with `T`.
[heading Header]
#include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/include/tag_of.hpp>
[heading Example]
typedef traits::tag_of<__list__<> >::type tag1;
typedef traits::tag_of<__list__<int> >::type tag2;
typedef traits::tag_of<__vector__<> >::type tag3;
typedef traits::tag_of<__vector__<int> >::type tag4;
BOOST_MPL_ASSERT((boost::is_same<tag1, tag2>));
BOOST_MPL_ASSERT((boost::is_same<tag3, tag4>));
[endsect]
[section category_of]
[heading Description]
A metafunction that establishes the conceptual classification of a particular
__sequence__ or __iterator__ (see __iterator_concepts__ and
__sequence_concepts__).
[heading Synopsis]
namespace traits
{
template <typename T>
struct category_of
{
typedef __unspecified__ type;
};
}
[heading Parameters]
[table
[[Parameter] [Requirement] [Description]]
[[`T`] [Any type] [The type to query.]]
]
[heading Expression Semantics]
typedef traits::category_of<T>::type category;
[*Return type]:
The return type is derived from one of:
namespace boost { namespace fusion
{
struct incrementable_traversal_tag {};
struct single_pass_traversal_tag
: incrementable_traversal_tag {};
struct forward_traversal_tag
: single_pass_traversal_tag {};
struct bidirectional_traversal_tag
: forward_traversal_tag {};
struct random_access_traversal_tag
: bidirectional_traversal_tag {};
}}
And optionally from:
namespace boost { namespace fusion
{
struct associative_tag {};
struct unbounded_tag {};
}}
[*Semantics]: Establishes the conceptual classification of a particular
__sequence__ or __iterator__.
[heading Header]
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/include/category_of.hpp>
[heading Example]
using boost::is_base_of;
typedef traits::category_of<__list__<> >::type list_category;
typedef traits::category_of<__vector__<> >::type vector_category;
BOOST_MPL_ASSERT(( is_base_of<forward_traversal_tag, list_category> ));
BOOST_MPL_ASSERT(( is_base_of<random_access_traversal_tag, vector_category> ));
[endsect]
[section deduce]
[heading Description]
Metafunction to apply __element_conversion__ to the full argument type.
It removes references to `const`, references to array types are kept, even
if the array is `const`. Reference wrappers are removed (see
__note_ref_wrappers__)[footnote Since C++11, the standard reference wrappers
are also removed.].
[heading Header]
#include <boost/fusion/support/deduce.hpp>
#include <boost/fusion/include/deduce.hpp>
[heading Synopsis]
namespace traits
{
template <typename T>
struct deduce
{
typedef __unspecified__ type;
};
}
[heading Example]
template <typename T>
struct holder
{
typename traits::deduce<T const &>::type element;
holder(T const & a)
: element(a)
{ }
};
template <typename T>
holder<T> make_holder(T const & a)
{
return holder<T>(a);
}
[heading See also]
* __deduce_sequence__
[endsect]
[section deduce_sequence]
[heading Description]
Applies __element_conversion__ to each element in a __forward_sequence__.
The resulting type is a __random_access_sequence__ that provides a converting
constructor accepting the original type as its argument.
[heading Header]
#include <boost/fusion/support/deduce_sequence.hpp>
#include <boost/fusion/include/deduce_sequence.hpp>
[heading Synopsis]
namespace traits
{
template <class Sequence>
struct deduce_sequence
{
typedef __unspecified__ type;
};
}
[heading Example]
template <class Seq>
struct holder
{
typename traits::deduce_sequence<Seq>::type element;
holder(Seq const & a)
: element(a)
{ }
};
template <typename T0, typename T1>
holder< __vector__<T0 const &, T1 const &> >
make_holder(T0 const & a0, T1 const & a1)
{
typedef __vector__<T0 const &, T1 const &> arg_vec_t;
return holder<arg_vec_t>( arg_vec_t(a0,a1) );
}
[heading See also]
* __deduce__
[endsect]
[section pair]
[heading Description]
Fusion `pair` type is a half runtime pair. A half runtime pair is similar
to a __std_pair__, but, unlike __std_pair__, the first type does not have data.
It is used as elements in __map__\ s, for example.
[heading Synopsis]
template <typename First, typename Second>
struct pair;
namespace result_of
{
template <typename Pair>
struct first;
template <typename Pair>
struct second;
template <typename First, typename Second>
struct make_pair;
}
template <typename First, typename Second>
typename result_of::make_pair<First,Second>::type
make_pair(Second const &);
[heading Template parameters]
[table
[[Parameter] [Description]]
[[First] [The first type. This is purely a type. No data is held.]]
[[Second] [The second type. This contains data.]]
]
[variablelist Notation
[[`P`] [Fusion pair type]]
[[`p`, `p2`] [Fusion pairs]]
[[`F`, `S`] [Arbitrary types]]
[[`s`] [Value of type `S`]]
[[`o`] [Output stream]]
[[`i`] [Input stream]]
]
[heading Expression Semantics]
[table
[[Expression] [Semantics]]
[[`P::first_type`] [The type of the first template parameter, `F`, equivalent to
`result_of::first<P>::type`. ]]
[[`P::second_type`] [The type of the second template parameter, `S`, equivalent to
`result_of::second<P>::type`. ]]
[[`P()`] [Default construction.]]
[[`P(s)`] [Construct a pair given value for the second type, `s`.]]
[[`P(p2)`] [Copy constructs a pair from another pair, `p2`.]]
[[`p.second`] [Get the data from `p1`.]]
[[`p = p2`] [Assigns a pair, `p1`, from another pair, `p2`.]]
[[make_pair<F>(s)] [Make a pair given the first type, `F`, and a value for
the second type, `s`. The second type assumes the type of `s`]]
[[`o << p`] [Output `p` to output stream, `o`.]]
[[`i >> p`] [Input `p` from input stream, `i`.]]
[[`p == p2`] [Tests two pairs for equality.]]
[[`p != p2`] [Tests two pairs for inequality.]]
]
[heading Header]
#include <boost/fusion/support/pair.hpp>
#include <boost/fusion/include/pair.hpp>
[heading Example]
pair<int, char> p('X');
std::cout << p << std::endl;
std::cout << make_pair<int>('X') << std::endl;
assert((p == make_pair<int>('X')));
[endsect]
[endsect]

View File

@ -1,287 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section Tuple]
The TR1 technical report describes extensions to the C++ standard library.
Many of these extensions will be considered for the next
iteration of the C++ standard. TR1 describes a tuple type, and
support for treating `std::pair` as a type of tuple.
Fusion provides full support for the __tr1__tuple__ interface, and the extended
uses of `std::pair` described in the TR1 document.
[section Class template tuple]
Fusion's implementation of the __tr1__tuple__ is also a fusion __forward_sequence__.
As such the fusion tuple type provides a lot of functionality beyond that required by TR1.
Currently tuple is basically a synonym for __vector__, although this may be changed
in future releases of fusion.
[heading Header]
#include <boost/fusion/tuple.hpp>
#include <boost/fusion/include/tuple.hpp>
#include <boost/fusion/tuple/tuple.hpp>
#include <boost/fusion/tuple/tuple_fwd.hpp>
#include <boost/fusion/include/tuple_fwd.hpp>
// for creation function
#include <boost/fusion/tuple/tuple_tie.hpp>
#include <boost/fusion/include/tuple_tie.hpp>
#include <boost/fusion/tuple/make_tuple.hpp>
#include <boost/fusion/include/make_tuple.hpp>
[heading Synopsis]
template<
typename T1 = __unspecified__,
typename T2 = __unspecified__,
...
typename TN = __unspecified__>
class tuple;
[section Construction]
[heading Description]
The __tr1__tuple__ type provides a default constructor, a constructor that takes initializers for all of its elements, a copy constructor, and a converting copy constructor. The details of the various constructors are described in this section.
[heading Specification]
[variablelist Notation
[[`T1 ... TN`, `U1 ... UN`][Tuple element types]]
[[`P1 ... PN`] [Parameter types]]
[[`Ti`, `Ui`] [The type of the `i`th element of a tuple]]
[[`Pi`] [The type of the `i`th parameter]]
]
tuple();
[*Requirements]: Each `Ti` is default-constructible.
[*Semantics]: Default initializes each element of the tuple.
tuple(P1,P2,...,PN);
[*Requirements]: Each `Pi` is `Ti` if `Ti` is a reference type, `const Ti&` otherwise.
[*Semantics]: Copy initializes each element with the corresponding parameter.
tuple(const tuple& t);
[*Requirements]: Each `Ti` should be copy-constructible.
[*Semantics]: Copy constructs each element of `*this` with the corresponding element of `t`.
template<typename U1, typename U2, ..., typename UN>
tuple(const tuple<U1, U2, ..., UN>& t);
[*Requirements]: Each `Ti` shall be constructible from the corresponding `Ui`.
[*Semantics]: Constructs each element of `*this` with the corresponding element of `t`.
[endsect]
[section Tuple creation functions]
[heading Description]
TR1 describes 2 utility functions for creating __tr1__tuple__. `make_tuple` builds a tuple out of it's argument list, and `tie` builds a tuple of references to it's arguments. The details of these creation functions are described in this section.
[heading Specification]
template<typename T1, typename T2, ..., typename TN>
tuple<V1, V2, ..., VN>
make_tuple(const T1& t1, const T2& t2, ..., const TN& tn);
Where `Vi` is `X&` if the cv-unqualified type `Ti` is `reference_wrapper<X>`, otherwise `Vi` is `Ti`.
[*Returns]: `tuple<V1, V2, ..., VN>(t1, t2, ..., tN)`
template<typename T1, typename T2, ..., typename TN>
tuple<T1&, T2&, ..., TN&>
tie(T1& t1, T2& t2, ..., TN& tn);
[*Returns]: tuple<T1&, T2&, ..., TN&>(t1, t2, ..., tN). When argument `ti` is `ignore`, assigning any value to the corresponding tuple element has no effect.
[endsect]
[section Tuple helper classes]
[heading Description]
The __tr1__tuple__ provides 2 helper traits, for compile time access to the tuple size, and the element types.
[heading Specification]
tuple_size<T>::value
[*Requires]: `T` is any fusion sequence type, including `tuple`.
[*Type]: __mpl_integral_constant__
[*Value]: The number of elements in the sequence. Equivalent to `__result_of_size__<T>::type`.
tuple_element<I, T>::type
[*Requires]: `T` is any fusion sequence type, including `tuple`. `0 <= I < N` or the program is ill formed.
[*Value]: The type of the `I`th element of `T`. Equivalent to `__result_of_value_at__<I,T>::type`.
[endsect]
[section Element access]
[heading Description]
The __tr1__tuple__ provides the `get` function to provide access to it's elements by zero based numeric index.
[heading Specification]
template<int I, T>
RJ get(T& t);
[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds.
`T` is any fusion sequence type, including `tuple`.
[*Return type]: `RJ` is equivalent to `__result_of_at_c__<I,T>::type`.
[*Returns]: A reference to the `I`th element of `T`.
template<int I, typename T>
PJ get(T const& t);
[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds.
`T` is any fusion sequence type, including `tuple`.
[*Return type]: `PJ` is equivalent to `__result_of_at_c__<I,T>::type`.
[*Returns]: A const reference to the `I`th element of `T`.
[endsect]
[section Relational operators]
[heading Description]
The __tr1__tuple__ provides the standard boolean relational operators.
[heading Specification]
[variablelist Notation
[[`T1 ... TN`, `U1 ... UN`][Tuple element types]]
[[`P1 ... PN`] [Parameter types]]
[[`Ti`, `Ui`] [The type of the `i`th element of a tuple]]
[[`Pi`] [The type of the `i`th parameter]]
]
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator==(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(lhs) == __tuple_get__<i>(rhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns `true` if and only if `__tuple_get__<i>(lhs) == __tuple_get__<i>(rhs)` for all `i`.
For any 2 zero length tuples `e` and `f`, `e == f` returns `true`.
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator<(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(lhs) < __tuple_get__<i>(rhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns the lexicographical comparison of between `lhs` and `rhs`.
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator!=(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(lhs) == __tuple_get__<i>(rhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns `!(lhs == rhs)`.
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator<=(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(rhs) < __tuple_get__<i>(lhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns `!(rhs < lhs)`
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator>(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(rhs) < __tuple_get__<i>(lhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns `rhs < lhs`.
template<typename T1, typename T2, ..., typename TN,
typename U1, typename U2, ..., typename UN>
bool operator>=(
const tuple<T1, T2, ..., TN>& lhs,
const tuple<U1, U2, ..., UN>& rhs);
[*Requirements]: For all `i`, `1 <= i < N`, `__tuple_get__<i>(lhs) < __tuple_get__<i>(rhs)` is a valid
expression returning a type that is convertible to `bool`.
[*Semantics]: Returns `!(lhs < rhs)`.
[endsect]
[endsect]
[section Pairs]
[heading Description]
The __tr1__tuple__ interface is specified to provide uniform access to `std::pair` as if it were a 2 element tuple.
[heading Specification]
tuple_size<std::pair<T1, T2> >::value
[*Type]: An __mpl_integral_constant__
[*Value]: Returns 2, the number of elements in a pair.
tuple_element<0, std::pair<T1, T2> >::type
[*Type]: `T1`
[*Value]: Returns the type of the first element of the pair
tuple_element<1, std::pair<T1, T2> >::type
[*Type]: `T2`
[*Value]: Returns the type of the second element of the pair
template<int I, typename T1, typename T2>
P& get(std::pair<T1, T2>& pr);
template<int I, typename T1, typename T2>
const P& get(const std::pair<T1, T2>& pr);
[*Type]: If `I == 0` `P` is `T1`, else if `I == 1` `P` is `T2` else the program is ill-formed.
[*Returns: `pr.first` if `I == 0` else `pr.second`.
[endsect]
[endsect]

View File

@ -1,671 +0,0 @@
[/==============================================================================
Copyright (C) 2001-2011 Joel de Guzman
Copyright (C) 2006 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)
===============================================================================/]
[section View]
Views are sequences that do not actually contain data, but instead impart
an alternative presentation over the data from one or more underlying
sequences. Views are proxies. They provide an efficient yet purely
functional way to work on potentially expensive sequence operations. Views
are inherently lazy. Their elements are only computed on demand only when
the elements of the underlying sequence(s) are actually accessed. Views'
lazy nature make them very cheap to copy and be passed around by value.
[heading Header]
#include <boost/fusion/view.hpp>
#include <boost/fusion/include/view.hpp>
[section single_view]
`single_view` is a view into a value as a single element sequence.
[heading Header]
#include <boost/fusion/view/single_view.hpp>
#include <boost/fusion/include/single_view.hpp>
[heading Synopsis]
template <typename T>
struct single_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`T`] [Any type] []]
]
[heading Model of]
* __random_access_sequence__
[variablelist Notation
[[`S`] [A `single_view` type]]
[[`s`, `s2`] [Instances of `single_view`]]
[[`x`] [An instance of `T`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in __random_access_sequence__.
[table
[[Expression] [Semantics]]
[[`S(x)`] [Creates a `single_view` from `x`.]]
[[`S(s)`] [Copy constructs a `single_view` from another `single_view`, `s`.]]
[[`s = s2`] [Assigns to a `single_view`, `s`, from another `single_view`, `s2`.]]
]
[heading Example]
single_view<int> view(3);
std::cout << view << std::endl;
[endsect]
[section filter_view]
[heading Description]
`filter_view` is a view into a subset of its underlying sequence's elements
satisfying a given predicate (an __mpl__ metafunction). The `filter_view`
presents only those elements for which its predicate evaluates to
`mpl::true_`.
[heading Header]
#include <boost/fusion/view/filter_view.hpp>
#include <boost/fusion/include/filter_view.hpp>
[heading Synopsis]
template <typename Sequence, typename Pred>
struct filter_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [A __forward_sequence__] []]
[[`Pred`] [Unary Metafunction
returning an `mpl::bool_`] []]
]
[heading Model of]
* __forward_sequence__
* __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
[variablelist Notation
[[`F`] [A `filter_view` type]]
[[`f`, `f2`] [Instances of `filter_view`]]
[[`s`] [A __forward_sequence__]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in the implemented models.
[table
[[Expression] [Semantics]]
[[`F(s)`] [Creates a `filter_view` given a sequence, `s`.]]
[[`F(f)`] [Copy constructs a `filter_view` from another `filter_view`, `f`.]]
[[`f = f2`] [Assigns to a `filter_view`, `f`, from another `filter_view`, `f2`.]]
]
[heading Example]
using boost::mpl::_;
using boost::mpl::not_;
using boost::is_class;
typedef __vector__<std::string, char, long, bool, double> vector_type;
vector_type v("a-string", '@', 987654, true, 6.6);
filter_view<vector_type const, not_<is_class<_> > > view(v);
std::cout << view << std::endl;
[endsect]
[section iterator_range]
[heading Description]
`iterator_range` presents a sub-range of its underlying sequence delimited
by a pair of iterators.
[heading Header]
#include <boost/fusion/view/iterator_range.hpp>
#include <boost/fusion/include/iterator_range.hpp>
[heading Synopsis]
template <typename First, typename Last>
struct iterator_range;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`First`] [A fusion __iterator__] []]
[[`Last`] [A fusion __iterator__] []]
]
[heading Model of]
* __forward_sequence__, __bidirectional_sequence__ or
__random_access_sequence__ depending on the traversal characteristics (see
__traversal_concept__) of its underlying sequence.
* __associative_sequence__ if `First` and `Last` implement the __associative_iterator__ model.
[variablelist Notation
[[`IR`] [An `iterator_range` type]]
[[`f`] [An instance of `First`]]
[[`l`] [An instance of `Last`]]
[[`ir`, `ir2`] [Instances of `iterator_range`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in the implemented models.
[table
[[Expression] [Semantics]]
[[`IR(f, l)`] [Creates an `iterator_range` given iterators, `f` and `l`.]]
[[`IR(ir)`] [Copy constructs an `iterator_range` from another `iterator_range`, `ir`.]]
[[`ir = ir2`] [Assigns to a `iterator_range`, `ir`, from another `iterator_range`, `ir2`.]]
]
[heading Example]
char const* s = "Ruby";
typedef __vector__<int, char, double, char const*> vector_type;
vector_type vec(1, 'x', 3.3, s);
typedef __result_of_begin__<vector_type>::type A;
typedef __result_of_end__<vector_type>::type B;
typedef __result_of_next__<A>::type C;
typedef __result_of_prior__<B>::type D;
C c(vec);
D d(vec);
iterator_range<C, D> range(c, d);
std::cout << range << std::endl;
[endsect]
[section joint_view]
[heading Description]
`joint_view` presents a view which is a concatenation of two sequences.
[heading Header]
#include <boost/fusion/view/joint_view.hpp>
#include <boost/fusion/include/joint_view.hpp>
[heading Synopsis]
template <typename Sequence1, typename Sequence2>
struct joint_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence1`] [A __forward_sequence__] []]
[[`Sequence2`] [A __forward_sequence__] []]
]
[heading Model of]
* __forward_sequence__
* __associative_sequence__ if `Sequence1` and `Sequence2` implement the __associative_sequence__ model.
[variablelist Notation
[[`JV`] [A `joint_view` type]]
[[`s1`] [An instance of `Sequence1`]]
[[`s2`] [An instance of `Sequence2`]]
[[`jv`, `jv2`] [Instances of `joint_view`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in the implemented models.
[table
[[Expression] [Semantics]]
[[`JV(s1, s2)`] [Creates a `joint_view` given sequences, `s1` and `s2`.]]
[[`JV(jv)`] [Copy constructs a `joint_view` from another `joint_view`, `jv`.]]
[[`jv = jv2`] [Assigns to a `joint_view`, `jv`, from another `joint_view`, `jv2`.]]
]
[heading Example]
__vector__<int, char> v1(3, 'x');
__vector__<std::string, int> v2("hello", 123);
joint_view<
__vector__<int, char>
, __vector__<std::string, int>
> view(v1, v2);
std::cout << view << std::endl;
[endsect]
[section zip_view]
[heading Description]
`zip_view` presents a view which iterates over a collection of __sequence__(s) in parallel. A `zip_view`
is constructed from a __sequence__ of references to the component __sequence__s.
[heading Header]
#include <boost/fusion/view/zip_view.hpp>
#include <boost/fusion/include/zip_view.hpp>
[heading Synopsis]
template <typename Sequences>
struct zip_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequences`] [A __forward_sequence__ of references to other Fusion __sequence__s] []]
]
[heading Model of]
* __forward_sequence__, __bidirectional_sequence__ or
__random_access_sequence__ depending on the traversal characteristics (see
__traversal_concept__) of its underlying sequence.
[variablelist Notation
[[`ZV`] [A `zip_view` type]]
[[`s`] [An instance of `Sequences`]]
[[`zv1`, `zv2`] [Instances of `ZV`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in __forward_sequence__.
[table
[[Expression] [Semantics]]
[[`ZV(s)`] [Creates a `zip_view` given a sequence of references to the component __sequence__s.]]
[[`ZV(zv1)`] [Copy constructs a `zip_view` from another `zip_view`, `zv`.]]
[[`zv1 = zv2`] [Assigns to a `zip_view`, `zv`, from another `zip_view`, `zv2`.]]
]
[heading Example]
typedef __vector__<int,int> vec1;
typedef __vector__<char,char> vec2;
vec1 v1(1,2);
vec2 v2('a','b');
typedef __vector__<vec1&, vec2&> sequences;
std::cout << zip_view<sequences>(sequences(v1, v2)) << std::endl; // ((1 a) (2 b))
[endsect]
[section transform_view]
The unary version of `transform_view` presents a view of its underlying
sequence given a unary function object or function pointer. The binary
version of `transform_view` presents a view of 2 underlying sequences,
given a binary function object or function pointer. The `transform_view`
inherits the traversal characteristics (see __traversal_concept__) of
its underlying sequence or sequences.
[heading Header]
#include <boost/fusion/view/transform_view.hpp>
#include <boost/fusion/include/transform_view.hpp>
[heading Synopsis]
[*Unary Version]
template <typename Sequence, typename F1>
struct transform_view;
[*Binary Version]
template <typename Sequence1, typename Sequence2, typename F2>
struct transform_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [A __forward_sequence__] []]
[[`Sequence1`] [A __forward_sequence__] []]
[[`Sequence2`] [A __forward_sequence__] []]
[[`F1`] [A unary function object or function pointer. `__boost_result_of_call__<F1(E)>::type` is the return type of an instance of `F1` when called with a value of each element type `E` in the input sequence.] []]
[[`F2`] [A binary function object or function pointer. `__boost_result_of_call__<F2(E1, E2)>::type` is the return type of an instance of `F2` when called with a value of each corresponding pair of element type `E1` and `E2` in the input sequences.] []]
]
[heading Model of]
* __forward_sequence__, __bidirectional_sequence__ or
__random_access_sequence__ depending on the traversal characteristics (see
__traversal_concept__) of its underlying sequence.
[variablelist Notation
[[`TV`] [A `transform_view` type]]
[[`BTV`] [A binary `transform_view` type]]
[[`UTV`] [A unary `transform_view` type]]
[[`f1`] [An instance of `F1`]]
[[`f2`] [An instance of `F2`]]
[[`s`] [An instance of `Sequence`]]
[[`s1`] [An instance of `Sequence1`]]
[[`s2`] [An instance of `Sequence2`]]
[[`tv`, `tv2`] [Instances of `transform_view`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in __forward_sequence__, __bidirectional_sequence__ or
__random_access_sequence__ depending on the traversal characteristics (see
__traversal_concept__) of its underlying sequence or sequences.
[table
[[Expression] [Semantics]]
[[`UTV(s, f1)`] [Creates a unary `transform_view` given sequence,
`s` and unary function object or function pointer, `f1`.]]
[[`BTV(s1, s2, f2)`] [Creates a binary `transform_view` given sequences, `s1` and `s2`
and binary function object or function pointer, `f2`.]]
[[`TV(tv)`] [Copy constructs a `transform_view` from another `transform_view`, `tv`.]]
[[`tv = tv2`] [Assigns to a `transform_view`, `tv`, from another `transform_view`, `tv2`.]]
]
[heading Example]
struct square
{
template<typename Sig>
struct result;
template<typename U>
struct result<square(U)>
: remove_reference<U>
{};
template <typename T>
T operator()(T x) const
{
return x * x;
}
};
typedef __vector__<int, short, double> vector_type;
vector_type vec(2, 5, 3.3);
transform_view<vector_type, square> transform(vec, square());
std::cout << transform << std::endl;
[endsect]
[section reverse_view]
`reverse_view` presents a reversed view of underlying sequence. The first
element will be its last and the last element will be its first.
[heading Header]
#include <boost/fusion/view/reverse_view.hpp>
#include <boost/fusion/include/reverse_view.hpp>
[heading Synopsis]
template <typename Sequence>
struct reverse_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [A __bidirectional_sequence__] []]
]
[heading Model of]
* A model of __bidirectional_sequence__ if `Sequence` is a __bidirectional_sequence__
else, __random_access_sequence__ if `Sequence` is a __random_access_sequence__.
* __associative_sequence__ if `Sequence` implements the __associative_sequence__ model.
[variablelist Notation
[[`RV`] [A `reverse_view` type]]
[[`s`] [An instance of `Sequence`]]
[[`rv`, `rv2`] [Instances of `reverse_view`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in the implemented models.
[table
[[Expression] [Semantics]]
[[`RV(s)`] [Creates a unary `reverse_view` given sequence, `s`.]]
[[`RV(rv)`] [Copy constructs a `reverse_view` from another `reverse_view`, `rv`.]]
[[`rv = rv2`] [Assigns to a `reverse_view`, `rv`, from another `reverse_view`, `rv2`.]]
]
[heading Example]
typedef __vector__<int, short, double> vector_type;
vector_type vec(2, 5, 3.3);
reverse_view<vector_type> reverse(vec);
std::cout << reverse << std::endl;
[endsect]
[section nview]
[heading Description]
`nview` presents a view which iterates over a given __sequence__ in a specified order.
An `nview` is constructed from an arbitrary __sequence__ and a list of indices specifying
the elements to iterate over.
[heading Header]
#include <boost/fusion/view/nview.hpp>
#include <boost/fusion/include/nview.hpp>
[heading Synopsis]
template <typename Sequence, typename Indices>
struct nview;
template <typename Sequence, int I1, int I2 = -1, ...>
typename result_of::nview<Sequence, I1, I2, ...>::type
as_nview(Sequence& s);
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [An arbitrary Fusion __forward_sequence__]
[]]
[[`Indices`] [A `mpl::vector_c<int, ...>` holding the indices defining
the required iteration order.] []]
[[`I1`, `I2`, `I3`...] [A list of integers specifying the required
iteration order.] [`INT_MAX` for `I2`, `I3`...]]
]
[heading Model of]
* __random_access_sequence__ (see __traversal_concept__)
[variablelist Notation
[[`NV`] [A `nview` type]]
[[`s`] [An instance of `Sequences`]]
[[`nv1`, `nv2`] [Instances of `NV`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in __random_access_sequence__.
[table
[[Expression] [Semantics]]
[[`NV(s)`] [Creates an `nview` given a sequence and a list of indices.]]
[[`NV(nv1)`] [Copy constructs an `nview` from another `nview`, `nv1`.]]
[[`nv1 = nv2`] [Assigns to an `nview`, `nv1`, from another `nview`, `nv2`.]]
]
The `nview` internally stores a Fusion __vector__ of references to the elements
of the original Fusion __sequence__
[heading Example]
typedef __vector__<int, char, double> vec;
typedef mpl::vector_c<int, 2, 1, 0, 2, 0> indices;
vec v1(1, 'c', 2.0);
std::cout << nview<vec, indices>(v1) << std::endl; // (2.0 c 1 2.0 1)
std::cout << as_nview<2, 1, 1, 0>(v1) << std::endl; // (2.0 c c 1)
[endsect]
[section repetitive_view]
[heading Description]
`repetitive_view` presents a view which iterates over a given
__sequence__ repeatedly. Because a `repetitive_view`
has infinite length, it can only be used when some external
condition determines the end. Thus, initializing a fixed
length sequence with a `repetitive_view` is okay, but
printing a `repetitive_view` to `std::cout` is not.
[heading Header]
#include <boost/fusion/view/repetitive_view.hpp>
#include <boost/fusion/include/repetitive_view.hpp>
[heading Synopsis]
template <typename Sequence>
struct repetitive_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [An arbitrary Fusion __forward_sequence__]
[]]
]
[variablelist Notation
[[`RV`] [A `repetitive_view` type]]
[[`s`] [An instance of `Sequences`]]
[[`rv`, `rv1`, `rv2`] [Instances of `RV`]]
]
[heading Expression Semantics]
[table
[[Expression] [Return Type] [Semantics]]
[[`RV(s)`] [] [Creates an `repetitive_view` given the underlying sequence.]]
[[`RV(rv1)`] [] [Copy constructs an `repetitive_view` from another `repetitive_view`, `rv1`.]]
[[`rv1 = rv2`] [] [Assigns to a `repetitive_view`, `rv1`, from another `repetitive_view`, `rv2`.]]
[[`__begin__(rv)`] [__forward_iterator__] []]
[[`__end__(rv)`] [__forward_iterator__] [Creates an unreachable iterator (since the sequence is infinite)]]
]
[heading Result Type Expressions]
[table
[[Expression]]
[[`__result_of_begin__<RV>::type`]]
[[`__result_of_end__<RV>::type`]]
]
[heading Example]
typedef __vector__<int, char, double> vec1;
typedef __vector__<int, char, double, int, char> vec2;
vec1 v1(1, 'c', 2.0);
vec2 v2(repetitive_view<vec1>(v1));
std::cout << v2 << std::endl; // 1, 'c', 2.0, 1, 'c'
[endsect]
[section flatten_view]
[heading Description]
`flatten_view` presents a view which iterates over its elements recursively in depth-first order.
[heading Header]
#include <boost/fusion/view/flatten_view.hpp>
#include <boost/fusion/include/flatten_view.hpp>
[heading Synopsis]
template <typename Sequence>
struct flatten_view;
[heading Template parameters]
[table
[[Parameter] [Description] [Default]]
[[`Sequence`] [A __forward_sequence__] []]
]
[heading Model of]
* __forward_sequence__
[variablelist Notation
[[`F`] [A `flatten_view` type]]
[[`s`] [An instance of `Sequence`]]
[[`f`, `f2`] [Instances of `F`]]
]
[heading Expression Semantics]
Semantics of an expression is defined only where it differs from, or is not
defined in __forward_sequence__.
[table
[[Expression] [Semantics]]
[[`F(s)`] [Creates a `flatten_view` given sequence, `s`.]]
[[`F(f)`] [Copy constructs a `flatten_view` from another `flatten_view`, `f`.]]
[[`f = f2`] [Assigns to a `flatten_view`, `f`, from another `flatten_view`, `f2`.]]
]
[heading Example]
typedef __vector__<int, int, __vector__<int, int>, int> sequence_type;
sequence_type seq;
__flatten_view__<sequence_type> flattened(seq);
__copy__(__make_vector__(1, 2, 3, 4, 5), flattened);
assert(seq == __make_vector__(1, 2, __make_vector__(3, 4), 5));
[endsect]
[endsect]

View File

@ -1,268 +0,0 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
Problem:
How to "do the Bind?"
This recipe shows how to implement a function binder, similar to
Boost.Bind based on the Functional module of Fusion.
It works as follows:
'bind' is a global, stateless function object. It is implemented in
fused form (fused_binder) and transformed into a variadic function
object. When called, 'bind' returns another function object, which
holds the arguments of the call to 'bind'. It is, again, implemented
in fused form (fused_bound_function) and transformed into unfused
form.
==============================================================================*/
#include <boost/fusion/functional/invocation/invoke.hpp>
#include <boost/fusion/functional/adapter/unfused.hpp>
#include <boost/fusion/support/deduce_sequence.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/algorithm/transformation/pop_front.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/view/filter_view.hpp>
#include <boost/functional/forward_adapter.hpp>
#include <boost/functional/lightweight_forward_adapter.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/max.hpp>
#include <boost/mpl/next.hpp>
#include <boost/ref.hpp>
#include <iostream>
#include <typeinfo>
namespace impl
{
namespace fusion = boost::fusion;
namespace traits = boost::fusion::traits;
namespace result_of = boost::fusion::result_of;
namespace mpl = boost::mpl;
using mpl::placeholders::_;
// Placeholders (we inherit from mpl::int_, so we can use placeholders
// as indices for fusion::at, later)
template <int I> struct placeholder : mpl::int_<I> { };
// A traits class to find out whether T is a placeholeder
template <typename T> struct is_placeholder : mpl::false_ { };
template <int I> struct is_placeholder< placeholder<I> > : mpl::true_ { };
template <int I> struct is_placeholder< placeholder<I> & > : mpl::true_ { };
template <int I> struct is_placeholder< placeholder<I> const > : mpl::true_ { };
template <int I> struct is_placeholder< placeholder<I> const & > : mpl::true_ { };
// This class template provides a Polymorphic Function Object to be used
// with fusion::transform. It is applied to the sequence of arguments that
// describes the binding and holds a reference to the sequence of arguments
// from the final call.
template<class FinalArgs> struct argument_transform
{
FinalArgs const & ref_final_args;
public:
explicit argument_transform(FinalArgs const & final_args)
: ref_final_args(final_args)
{ }
// A placeholder? Replace it with an argument from the final call...
template <int Index>
inline typename result_of::at_c<FinalArgs const, Index>::type
operator()(placeholder<Index> const &) const
{
return fusion::at_c<Index>(this->ref_final_args);
}
// ...just return the bound argument, otherwise.
template <typename T> inline T & operator()(T & bound) const
{
return bound;
}
template <typename Signature>
struct result;
template <class Self, typename T>
struct result< Self (T) >
: mpl::eval_if< is_placeholder<T>,
result_of::at<FinalArgs,typename boost::remove_reference<T>::type>,
mpl::identity<T>
>
{ };
};
// Fused implementation of the bound function, the function object
// returned by bind
template <class BindArgs> class fused_bound_function
{
// Transform arguments to be held by value
typedef typename traits::deduce_sequence<BindArgs>::type bound_args;
bound_args fsq_bind_args;
public:
fused_bound_function(BindArgs const & bind_args)
: fsq_bind_args(bind_args)
{ }
template <typename Signature>
struct result;
template <class FinalArgs>
struct result_impl
: result_of::invoke< typename result_of::front<bound_args>::type,
typename result_of::transform<
typename result_of::pop_front<bound_args>::type,
argument_transform<FinalArgs> const
>::type
>
{ };
template <class Self, class FinalArgs>
struct result< Self (FinalArgs) >
: result_impl< typename boost::remove_reference<FinalArgs>::type >
{ };
template <class FinalArgs>
inline typename result_impl<FinalArgs>::type
operator()(FinalArgs const & final_args) const
{
return fusion::invoke( fusion::front(this->fsq_bind_args),
fusion::transform( fusion::pop_front(this->fsq_bind_args),
argument_transform<FinalArgs>(final_args) ) );
}
// Could add a non-const variant - omitted for readability
};
// Find the number of placeholders in use
struct n_placeholders
{
struct fold_op
{
template <typename Sig> struct result;
template <class S, class A, class B> struct result< S(A &,B &) >
: mpl::max<A,B> { };
};
struct filter_pred
{
template <class X> struct apply : is_placeholder<X> { };
};
template <typename Seq>
struct apply
: mpl::next< typename result_of::fold<
fusion::filter_view<Seq,filter_pred>, mpl::int_<-1>, fold_op
>::type>::type
{ };
};
// Fused implementation of the 'bind' function
struct fused_binder
{
template <class Signature>
struct result;
template <class BindArgs,
int Placeholders = n_placeholders::apply<BindArgs>::value>
struct result_impl
{
typedef boost::forward_adapter<fusion::unfused<
fused_bound_function<BindArgs>,!Placeholders>,Placeholders> type;
};
template <class Self, class BindArgs>
struct result< Self (BindArgs) >
: result_impl< typename boost::remove_reference<BindArgs>::type >
{ };
template <class BindArgs>
inline typename result_impl< BindArgs >::type
operator()(BindArgs & bind_args) const
{
return typename result< void(BindArgs) >::type(
fusion::unfused< fused_bound_function<BindArgs>,
! n_placeholders::apply<BindArgs>::value >(bind_args) );
}
};
// The binder's unfused type. We use lightweght_forward_adapter to make
// that thing more similar to Boost.Bind. Because of that we have to use
// Boost.Ref (below in the sample code)
typedef boost::lightweight_forward_adapter< fusion::unfused<fused_binder> > binder;
}
// Placeholder globals
impl::placeholder<0> const _1_ = impl::placeholder<0>();
impl::placeholder<1> const _2_ = impl::placeholder<1>();
impl::placeholder<2> const _3_ = impl::placeholder<2>();
impl::placeholder<3> const _4_ = impl::placeholder<3>();
// The bind function is a global, too
impl::binder const bind = impl::binder();
// OK, let's try it out:
struct func
{
typedef int result_type;
inline int operator()() const
{
std::cout << "operator()" << std::endl;
return 0;
}
template <typename A>
inline int operator()(A const & a) const
{
std::cout << "operator()(A const & a)" << std::endl;
std::cout << " a = " << a << " A = " << typeid(A).name() << std::endl;
return 1;
}
template <typename A, typename B>
inline int operator()(A const & a, B & b) const
{
std::cout << "operator()(A const & a, B & b)" << std::endl;
std::cout << " a = " << a << " A = " << typeid(A).name() << std::endl;
std::cout << " b = " << b << " B = " << typeid(B).name() << std::endl;
return 2;
}
};
int main()
{
func f;
int value = 42;
using boost::ref;
int errors = 0;
errors += !( bind(f)() == 0);
errors += !( bind(f,"Hi")() == 1);
errors += !( bind(f,_1_)("there.") == 1);
errors += !( bind(f,"The answer is",_1_)(12) == 2);
errors += !( bind(f,_1_,ref(value))("Really?") == 2);
errors += !( bind(f,_1_,_2_)("Dunno. If there is an answer, it's",value) == 2);
return !! errors;
}

View File

@ -1,105 +0,0 @@
/*=============================================================================
Copyright (c) 2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Problem:
So... you have an input sequence I and a target vector R. You want to
copy I into R. But, I may have less elements than the result vector R.
For those elements not in R, you want them to be default constructed.
Here's a case:
I: list<double, std::string>
R: vector<double, std::string, int, short>
You want the elements at the right of I not in R (i.e. int, short)
default constructed. Those at the left, found in both I and R, you want
to simply copy from I.
Of course you want to be able to handle any type of I and R.
==============================================================================*/
// We'll use these containers as examples
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
// For doing I/O
#include <boost/fusion/sequence/io.hpp>
// We'll use join and advance for processing
#include <boost/fusion/algorithm/transformation/join.hpp>
#include <boost/fusion/iterator/advance.hpp>
// The fusion <--> MPL link header
#include <boost/fusion/mpl.hpp>
// Same-o same-o
#include <iostream>
#include <string>
int
main()
{
using namespace boost::fusion;
using namespace boost;
// Let's specify our own tuple delimeters for nicer printing
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
// Here's your input sequence
typedef list<double, std::string> I;
I i(123.456, "Hello");
// Here's your output sequence. For now, it is just a typedef
typedef vector<double, std::string, int, short> R;
// Let's get the sizes of the sequences. Yeah, you already know that.
// But with templates, you are simply given, say, R and I, corresponding
// to the types of the sequences. You'll have to deal with it generically.
static int const r_size = result_of::size<R>::value;
static int const i_size = result_of::size<I>::value;
// Make sure that I has no more elements than R
// Be nice and catch obvious errors earlier rather than later.
// Without this assert, the mistake will still be caught by Fusion,
// but the error will point to somewhere really obscure.
BOOST_STATIC_ASSERT(i_size <= r_size);
// Let's get the begin and end iterator types of the output sequence
// There's no actual vector yet. We just want to know the types.
typedef result_of::begin<R>::type r_begin;
typedef result_of::end<R>::type r_end;
// Let's skip i_size elements from r_begin. Again, we just want to know the type.
typedef result_of::advance_c<r_begin, i_size>::type r_advance;
// Now, make MPL iterators from r_advance and r_end. Ditto, just types.
typedef mpl::fusion_iterator<r_advance> mpl_r_advance;
typedef mpl::fusion_iterator<r_end> mpl_r_end;
// Make an mpl::iterator_range from the MPL iterators we just created
// You guessed it! --just a type.
typedef mpl::iterator_range<mpl_r_advance, mpl_r_end> tail;
// Use join to join the input sequence and our mpl::iterator_range
// Our mpl::iterator_range is 'tail'. Here, we'll actually instantiate
// 'tail'. Notice that this is a flyweight object, typically just 1 byte
// in size -- it doesn't really hold any data, but is a fully conforming
// sequence nonetheless. When asked to return its elements, 'tail' returns
// each element default constructed. Breeds like a rabbit!
// Construct R from the joined sequences:
R r(join(i, tail()));
// Then finally, print the result:
std::cout << r << std::endl;
return 0;
}

View File

@ -1,20 +0,0 @@
#==============================================================================
# Copyright (c) 2003-2006 Joel de Guzman
# Copyright (c) 2006 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)
#==============================================================================
# bring in rules for testing
import testing ;
{
test-suite example :
[ run test_example.cpp : : : : ]
[ run triple.cpp : : : : ]
;
}

View File

@ -1,47 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ADVANCE_IMPL_20060222_2150)
#define BOOST_FUSION_ADVANCE_IMPL_20060222_2150
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct advance_impl;
template<>
struct advance_impl<example::example_struct_iterator_tag>
{
template<typename Iterator, typename N>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example::example_struct_iterator<
struct_type, index::value + N::value> type;
static type
call(Iterator const& it)
{
return type(it.struct_);
}
};
};
}
}}
#endif

View File

@ -1,67 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_AT_IMPL_20060223_2017)
#define BOOST_FUSION_AT_IMPL_20060223_2017
#include <string>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_const.hpp>
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct at_impl;
template<>
struct at_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply;
template<typename Sequence>
struct apply<Sequence, mpl::int_<0> >
{
typedef typename mpl::if_<
is_const<Sequence>,
std::string const&,
std::string&>::type type;
static type
call(Sequence& seq)
{
return seq.name;
};
};
template<typename Sequence>
struct apply<Sequence, mpl::int_<1> >
{
typedef typename mpl::if_<
is_const<Sequence>,
int const&,
int&>::type type;
static type
call(Sequence& seq)
{
return seq.age;
};
};
};
}
}}
#endif

View File

@ -1,72 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_AT_KEY_IMPL_20060223_2017)
#define BOOST_FUSION_AT_KEY_IMPL_20060223_2017
#include <string>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
namespace fields
{
struct name;
struct age;
}
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct at_key_impl;
template<>
struct at_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply;
template<typename Sequence>
struct apply<Sequence, fields::name>
{
typedef typename mpl::if_<
is_const<Sequence>,
std::string const&,
std::string&>::type type;
static type
call(Sequence& seq)
{
return seq.name;
};
};
template<typename Sequence>
struct apply<Sequence, fields::age>
{
typedef typename mpl::if_<
is_const<Sequence>,
int const&,
int&>::type type;
static type
call(Sequence& seq)
{
return seq.age;
};
};
};
}
}}
#endif

View File

@ -1,43 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_BEGIN_IMPL_20060222_2042)
#define BOOST_FUSION_BEGIN_IMPL_20060222_2042
#include "../example_struct_iterator.hpp"
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct begin_impl;
template<>
struct begin_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef example::example_struct_iterator<Sequence, 0> type;
static type
call(Sequence& seq)
{
return type(seq);
}
};
};
}
}}
#endif

View File

@ -1,34 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037)
#define BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037
#include <boost/fusion/support/category_of.hpp>
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<>
struct category_of_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
struct type : random_access_traversal_tag, associative_tag {};
};
};
}
}}
#endif

View File

@ -1,30 +0,0 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_DEREF_DATA_IMPL_HPP
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct deref_data_impl;
template<>
struct deref_data_impl<example::example_struct_iterator_tag>
: deref_impl<example::example_struct_iterator_tag>
{};
}
}}
#endif

View File

@ -1,67 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_DEREF_IMPL_20060222_1952)
#define BOOST_FUSION_DEREF_IMPL_20060222_1952
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp>
#include <string>
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct deref_impl;
template<>
struct deref_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef typename mpl::if_<
is_const<Struct>, std::string const&, std::string&>::type type;
static type
call(example::example_struct_iterator<Struct, 0> const& it)
{
return it.struct_.name;
}
};
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef typename mpl::if_<
is_const<Struct>, int const&, int&>::type type;
static type
call(example::example_struct_iterator<Struct, 1> const& it)
{
return it.struct_.age;
}
};
};
}
}}
#endif

View File

@ -1,44 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_DISTANCE_IMPL_20060223_0814)
#define BOOST_FUSION_DISTANCE_IMPL_20060223_0814
#include <boost/mpl/minus.hpp>
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct distance_impl;
template<>
struct distance_impl<example::example_struct_iterator_tag>
{
template<typename First, typename Last>
struct apply
: mpl::minus<typename Last::index, typename First::index>
{
typedef apply<First, Last> self;
static typename self::type
call(First const& first, Last const& last)
{
return typename self::type();
}
};
};
}
}}
#endif

View File

@ -1,43 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_END_IMPL_20060222_2042)
#define BOOST_FUSION_END_IMPL_20060222_2042
#include "../example_struct_iterator.hpp"
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct end_impl;
template<>
struct end_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef example::example_struct_iterator<Sequence, 2> type;
static type
call(Sequence& seq)
{
return type(seq);
}
};
};
}
}}
#endif

View File

@ -1,38 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941)
#define BOOST_FUSION_EQUAL_TO_IMPL_20060223_1941
#include <boost/mpl/equal_to.hpp>
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct equal_to_impl;
template<>
struct equal_to_impl<example::example_struct_iterator_tag>
{
template<typename It1, typename It2>
struct apply
: mpl::equal_to<
typename It1::index,
typename It2::index>
{};
};
}
}}
#endif

View File

@ -1,45 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_HAS_KEY_IMPL_20060223_2156)
#define BOOST_FUSION_HAS_KEY_IMPL_20060223_2156
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/or.hpp>
namespace fields
{
struct name;
struct age;
}
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct has_key_impl;
template<>
struct has_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply
: mpl::or_<
is_same<Key, fields::name>,
is_same<Key, fields::age> >
{};
};
}
}}
#endif

View File

@ -1,34 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946)
#define BOOST_FUSION_IS_SEQUENCE_IMPL_20060228_1946
#include <boost/mpl/bool.hpp>
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion
{
namespace extension
{
template<typename Tag>
struct is_sequence_impl;
template<>
struct is_sequence_impl<example::example_sequence_tag>
{
template<typename T>
struct apply : mpl::true_ {};
};
}
}}
#endif

View File

@ -1,32 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_IS_VIEW_IMPL_200604227_2150)
#define BOOST_FUSION_IS_VIEW_IMPL_200604227_2150
#include <boost/mpl/bool.hpp>
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion
{
namespace extension
{
template<typename Tag>
struct is_view_impl;
template<>
struct is_view_impl<example::example_sequence_tag>
: boost::mpl::false_
{};
}
}}
#endif

View File

@ -1,42 +0,0 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_KEY_OF_IMPL_HPP
#include <boost/mpl/if.hpp>
namespace fields
{
struct name;
struct age;
}
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct key_of_impl;
template<>
struct key_of_impl<example::example_struct_iterator_tag>
{
template<typename It>
struct apply
: mpl::if_c<!It::index::value, fields::name, fields::age>
{};
};
}
}}
#endif

View File

@ -1,46 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_NEXT_IMPL_20060222_1859)
#define BOOST_FUSION_NEXT_IMPL_20060222_1859
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct next_impl;
template<>
struct next_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example::example_struct_iterator<struct_type, index::value + 1> type;
static type
call(Iterator const& i)
{
return type(i.struct_);
}
};
};
}
}}
#endif

View File

@ -1,46 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_PRIOR_IMPL_20060222_1944)
#define BOOST_FUSION_PRIOR_IMPL_20060222_1944
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct prior_impl;
template<>
struct prior_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example::example_struct_iterator<struct_type, index::value - 1> type;
static type
call(Iterator const& i)
{
return type(i.struct_);
}
};
};
}
}}
#endif

View File

@ -1,36 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_SIZE_IMPL_20060223_2033)
#define BOOST_FUSION_SIZE_IMPL_20060223_2033
#include <boost/mpl/int.hpp>
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct size_impl;
template<>
struct size_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
: mpl::int_<2>
{};
};
}
}}
#endif

View File

@ -1,44 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_VALUE_AT_IMPL_20060223_2025)
#define BOOST_FUSION_VALUE_AT_IMPL_20060223_2025
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct value_at_impl;
template<>
struct value_at_impl<example::example_sequence_tag>
{
template<typename Sequence, typename N>
struct apply;
template<typename Sequence>
struct apply<Sequence, mpl::int_<0> >
{
typedef std::string type;
};
template<typename Sequence>
struct apply<Sequence, mpl::int_<1> >
{
typedef int type;
};
};
}
}}
#endif

View File

@ -1,50 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025)
#define BOOST_FUSION_VALUE_AT_KEY_IMPL_20060223_2025
namespace fields
{
struct name;
struct age;
}
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct value_at_key_impl;
template<>
struct value_at_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename N>
struct apply;
template<typename Sequence>
struct apply<Sequence, fields::name>
{
typedef std::string type;
};
template<typename Sequence>
struct apply<Sequence, fields::age>
{
typedef int type;
};
};
}
}}
#endif

View File

@ -1,30 +0,0 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_VALUE_OF_DATA_IMPL_HPP
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct value_of_data_impl;
template<>
struct value_of_data_impl<example::example_struct_iterator_tag>
: value_of_impl<example::example_struct_iterator_tag>
{};
}
}}
#endif

View File

@ -1,49 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_VALUE_OF_IMPL_20060223_1905)
#define BOOST_FUSION_VALUE_OF_IMPL_20060223_1905
#include <string>
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct value_of_impl;
template<>
struct value_of_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef std::string type;
};
template<typename Struct>
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef int type;
};
};
}
}}
#endif

View File

@ -1,25 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT)
#define BOOST_FUSION_EXAMPLE_STRUCT
#include "./tag_of.hpp"
#include "./example_struct_iterator.hpp"
#include "./detail/begin_impl.hpp"
#include "./detail/end_impl.hpp"
#include "./detail/at_impl.hpp"
#include "./detail/value_at_impl.hpp"
#include "./detail/size_impl.hpp"
#include "./detail/category_of_impl.hpp"
#include "./detail/at_key_impl.hpp"
#include "./detail/value_at_key_impl.hpp"
#include "./detail/has_key_impl.hpp"
#include "./detail/is_sequence_impl.hpp"
#include "./detail/is_view_impl.hpp"
#endif

View File

@ -1,70 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR)
#define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/static_assert.hpp>
#include "./detail/next_impl.hpp"
#include "./detail/prior_impl.hpp"
#include "./detail/deref_impl.hpp"
#include "./detail/advance_impl.hpp"
#include "./detail/distance_impl.hpp"
#include "./detail/value_of_impl.hpp"
#include "./detail/equal_to_impl.hpp"
#include "./detail/key_of_impl.hpp"
#include "./detail/value_of_data_impl.hpp"
#include "./detail/deref_data_impl.hpp"
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
namespace traits
{
template<typename Struct, int Pos>
struct tag_of<example::example_struct_iterator<Struct, Pos> >
{
typedef example::example_struct_iterator_tag type;
};
}
}}
namespace example {
template<typename Struct, int Pos>
struct example_struct_iterator
: boost::fusion::iterator_base<example_struct_iterator<Struct, Pos> >
{
BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
typedef Struct struct_type;
typedef boost::mpl::int_<Pos> index;
struct category
: boost::fusion::random_access_traversal_tag
, boost::fusion::associative_tag
{};
example_struct_iterator(Struct& str)
: struct_(str) {}
Struct& struct_;
};
}
#endif

View File

@ -1,27 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_EXAMPLE_STRUCT_TYPE)
#define BOOST_FUSION_EXAMPLE_STRUCT_TYPE
#include <string>
namespace example
{
struct example_struct
{
std::string name;
int age;
example_struct(
const std::string& n,
int a)
: name(n), age(a)
{}
};
}
#endif

View File

@ -1,30 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_TAG_OF_20060222_2052)
#define BOOST_FUSION_TAG_OF_20060222_2052
#include <boost/fusion/support/tag_of_fwd.hpp>
#include "./example_struct_type.hpp"
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace traits {
template<>
struct tag_of<example::example_struct>
{
typedef example::example_sequence_tag type;
};
}}}
#endif

View File

@ -1,65 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include "./example_struct.hpp"
#include "./example_struct_type.hpp"
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/assert.hpp>
int main()
{
example::example_struct bert("bert", 99);
using namespace boost::fusion;
BOOST_MPL_ASSERT((traits::is_associative<example::example_struct>));
BOOST_MPL_ASSERT((traits::is_random_access<example::example_struct>));
BOOST_MPL_ASSERT((traits::is_sequence<example::example_struct>));
BOOST_TEST(deref(begin(bert)) == "bert");
BOOST_TEST(*next(begin(bert)) == 99);
BOOST_TEST(*prior(end(bert)) == 99);
BOOST_TEST(*advance_c<1>(begin(bert)) == 99);
BOOST_TEST(*advance_c<-1>(end(bert)) == 99);
BOOST_TEST(distance(begin(bert), end(bert)) == 2);
typedef result_of::begin<example::example_struct>::type first;
typedef result_of::next<first>::type second;
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<first>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_of<second>::type, int>));
BOOST_TEST(begin(bert) != end(bert));
BOOST_TEST(advance_c<2>(begin(bert)) == end(const_cast<const example::example_struct&>(bert)));
BOOST_TEST(at_c<0>(bert) == "bert");
BOOST_TEST(at_c<1>(bert) == 99);
BOOST_TEST(at_key<fields::name>(bert) == "bert");
BOOST_TEST(at_key<fields::age>(bert) == 99);
BOOST_TEST(has_key<fields::name>(bert));
BOOST_TEST(has_key<fields::age>(bert));
BOOST_TEST(!has_key<int>(bert));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_c<example::example_struct, 0>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_c<example::example_struct, 1>::type, int>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::name>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::age>::type, int>));
BOOST_TEST(deref_data(begin(bert)) == "bert");
BOOST_TEST(deref_data(next(begin(bert))) == 99);
BOOST_TEST(size(bert) == 2);
return boost::report_errors();
}

View File

@ -1,377 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2011 Nathan Ridge
Copyright (c) 2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
/*=============================================================================
An implementation of a std::pair like triple<T0, T1, T2>
We use fusion::sequence_facade and fusion::iterator_facade
to make our triple a fully conforming Boost.Fusion random
traversal sequence.
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/sequence/sequence_facade.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <string>
namespace mpl = boost::mpl;
namespace fusion = boost::fusion;
namespace demo
{
template<typename Seq, int N>
struct triple_iterator
: fusion::iterator_facade<triple_iterator<Seq, N>,
fusion::random_access_traversal_tag>
{
typedef mpl::int_<N> index;
typedef Seq sequence_type;
triple_iterator(Seq& seq)
: seq_(seq) {}
Seq& seq_;
template<typename T>
struct value_of;
template<typename Sq>
struct value_of<triple_iterator<Sq, 0> >
: mpl::identity<typename Sq::t0_type>
{};
template<typename Sq>
struct value_of<triple_iterator<Sq, 1> >
: mpl::identity<typename Sq::t1_type>
{};
template<typename Sq>
struct value_of<triple_iterator<Sq, 2> >
: mpl::identity<typename Sq::t2_type>
{};
template<typename T>
struct deref;
template <typename Sq>
struct deref<triple_iterator<Sq, 0> >
{
typedef typename Sq::t0_type& type;
static type
call(triple_iterator<Sq, 0> const& iter)
{
return iter.seq_.t0;
}
};
template <typename Sq>
struct deref<triple_iterator<Sq, 0> const>
{
typedef typename Sq::t0_type const& type;
static type
call(triple_iterator<Sq, 0> const& iter)
{
return iter.seq_.t0;
}
};
template <typename Sq>
struct deref<triple_iterator<Sq, 1> >
{
typedef typename Sq::t1_type& type;
static type
call(triple_iterator<Sq, 1> const& iter)
{
return iter.seq_.t1;
}
};
template <typename Sq>
struct deref<triple_iterator<Sq, 1> const>
{
typedef typename Sq::t1_type const& type;
static type
call(triple_iterator<Sq, 1> const& iter)
{
return iter.seq_.t1;
}
};
template <typename Sq>
struct deref<triple_iterator<Sq, 2> >
{
typedef typename Sq::t2_type& type;
static type
call(triple_iterator<Sq, 2> const& iter)
{
return iter.seq_.t2;
}
};
template <typename Sq>
struct deref<triple_iterator<Sq, 2> const>
{
typedef typename Sq::t2_type const& type;
static type
call(triple_iterator<Sq, 2> const& iter)
{
return iter.seq_.t2;
}
};
template<typename It>
struct next
{
typedef triple_iterator<
typename It::sequence_type, It::index::value + 1>
type;
static type call(It const& it)
{
return type(it.seq_);
}
};
template<typename It>
struct prior
{
typedef triple_iterator<
typename It::sequence_type, It::index::value - 1>
type;
static type call(It const& it)
{
return type(it.seq_);
}
};
template<typename It1, typename It2>
struct distance
{
typedef typename mpl::minus<
typename It2::index, typename It1::index>::type
type;
static type call(It1 const& it1, It2 const& it2)
{
return type();
}
};
template<typename It, typename M>
struct advance
{
typedef triple_iterator<
typename It::sequence_type,
It::index::value + M::value>
type;
static type call(It const& it)
{
return type(it.seq_);
}
};
};
template<typename T0, typename T1, typename T2>
struct triple
: fusion::sequence_facade<triple<T0, T1, T2>,
fusion::random_access_traversal_tag>
{
triple(T0 const& t0, T1 const& t1, T2 const& t2)
: t0(t0), t1(t1), t2(t2)
{}
template<typename Sq>
struct begin
{
typedef demo::triple_iterator<Sq, 0> type;
static type call(Sq& sq)
{
return type(sq);
}
};
template<typename Sq>
struct end
{
typedef demo::triple_iterator<Sq, 3> type;
static type call(Sq& sq)
{
return type(sq);
}
};
template<typename Sq>
struct size
: mpl::int_<3>
{};
template<typename Sq, typename N>
struct value_at
: value_at<Sq, mpl::int_<N::value> >
{};
template<typename Sq>
struct value_at<Sq, mpl::int_<0> >
{
typedef typename Sq::t0_type type;
};
template<typename Sq>
struct value_at<Sq, mpl::int_<1> >
{
typedef typename Sq::t1_type type;
};
template<typename Sq>
struct value_at<Sq, mpl::int_<2> >
{
typedef typename Sq::t2_type type;
};
template<typename Sq, typename N>
struct at
: at<Sq, mpl::int_<N::value> >
{};
template<typename Sq>
struct at<Sq, mpl::int_<0> >
{
typedef typename
mpl::if_<
boost::is_const<Sq>
, typename Sq::t0_type const&
, typename Sq::t0_type&
>::type
type;
static type call(Sq& sq)
{
return sq.t0;
}
};
template<typename Sq>
struct at<Sq, mpl::int_<1> >
{
typedef typename
mpl::if_<
boost::is_const<Sq>
, typename Sq::t1_type const&
, typename Sq::t1_type&
>::type
type;
static type call(Sq& sq)
{
return sq.t1;
}
};
template<typename Sq>
struct at<Sq, mpl::int_<2> >
{
typedef typename
mpl::if_<
boost::is_const<Sq>
, typename Sq::t2_type const&
, typename Sq::t2_type&
>::type
type;
static type call(Sq& sq)
{
return sq.t2;
}
};
typedef T0 t0_type;
typedef T1 t1_type;
typedef T2 t2_type;
T0 t0;
T1 t1;
T2 t2;
};
}
struct modifying_fold_functor
{
template <typename T>
struct result
{
typedef bool type;
};
template <typename T>
bool operator()(bool b, T&)
{
return b;
}
};
struct nonmodifying_fold_functor
{
template <typename T>
struct result
{
typedef bool type;
};
template <typename T>
bool operator()(bool b, const T&)
{
return b;
}
};
int main()
{
typedef demo::triple<int, char, std::string> my_triple;
my_triple t(101, 'a', "hello");
BOOST_TEST(*fusion::begin(t) == 101);
BOOST_TEST(*fusion::next(fusion::begin(t)) == 'a');
BOOST_TEST(*fusion::prior(fusion::end(t)) == "hello");
BOOST_TEST(fusion::distance(fusion::begin(t), fusion::end(t)) == 3);
BOOST_TEST(fusion::size(t) == 3);
BOOST_MPL_ASSERT((boost::is_same<
int, fusion::result_of::value_at_c<my_triple, 0>::type>));
BOOST_MPL_ASSERT((boost::is_same<
char, fusion::result_of::value_at_c<my_triple, 1>::type>));
BOOST_MPL_ASSERT((boost::is_same<
std::string, fusion::result_of::value_at_c<my_triple, 2>::type>));
BOOST_TEST(fusion::at_c<0>(t) == 101);
BOOST_TEST(fusion::at_c<1>(t) == 'a');
BOOST_TEST(fusion::at_c<2>(t) == "hello");
BOOST_TEST(fusion::fold(t, true, modifying_fold_functor()) == true);
BOOST_TEST(fusion::fold(t, true, nonmodifying_fold_functor()) == true);
return boost::report_errors();
}

View File

@ -1,20 +0,0 @@
#==============================================================================
# Copyright (c) 2003-2006 Joel de Guzman
# Copyright (c) 2006 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)
#==============================================================================
project fusion-performance ;
exe accumulate : accumulate.cpp ;
exe inner_product : inner_product.cpp ;
exe inner_product2 : inner_product2.cpp ;
exe sequence_efficiency : sequence_efficiency.cpp ;
exe functional : functional.cpp ;

View File

@ -1,357 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/array.hpp>
#include <boost/timer.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/adapted/array.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <cmath>
#include <limits>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
int const REPEAT_COUNT = 10;
double const duration = 0.5;
namespace
{
template<int N>
double time_for_std_accumulate(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr;
std::generate(arr.begin(), arr.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::accumulate(arr.begin(), arr.end(), 0);
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::accumulate(arr.begin(), arr.end(), 0);
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
struct poly_add
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_add(Lhs,Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + rhs;
}
};
struct poly_mult
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_mult(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs * rhs;
}
};
template<int N>
double time_for_fusion_accumulate(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr;
std::generate(arr.begin(), arr.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(arr, 0, poly_add());
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
std::cout << iter << " iterations" << std::endl;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(arr, 0, poly_add());
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
std::cout << ".";
std::cout.flush();
}
std::cout << i << std::endl;
return result / iter;
}
#if 0
template<int N>
double time_for_std_inner_product(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
template<int N>
double time_for_fusion_inner_product(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::transform(arr1, arr2, poly_mult()), 0, poly_add());
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::transform(arr1, arr2, poly_mult()), 0, poly_add());
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
struct poly_combine
{
template<typename Lhs, typename Rhs>
struct result
{
typedef Lhs type;
};
template<typename Lhs, typename Rhs>
typename result<Lhs,Rhs>::type
operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + boost::fusion::at_c<0>(rhs) * boost::fusion::at_c<1>(rhs);
}
};
template<int N>
double time_for_fusion_inner_product2(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::zip(arr1, arr2), 0, poly_combine());
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
std::cout << iter << " iterations" << std::endl;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::zip(arr1, arr2), 0, poly_combine());
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
#endif
}
int main()
{
int total = 0;
int res;
std::cout << "short accumulate std test " << time_for_std_accumulate<8>(res) << std::endl;
total += res;
std::cout << "short accumulate fusion test " << time_for_fusion_accumulate<8>(res) << std::endl;
total += res;
std::cout << "medium accumulate std test " << time_for_std_accumulate<64>(res) << std::endl;
total += res;
std::cout << "medium accumulate fusion test " << time_for_fusion_accumulate<64>(res) << std::endl;
total += res;
std::cout << "long accumulate std test " << time_for_std_accumulate<128>(res) << std::endl;
total += res;
std::cout << "long accumulate fusion test " << time_for_fusion_accumulate<128>(res) << std::endl;
total += res;
#if 0
std::cout << "short inner_product std test " << time_for_std_inner_product<8>(res) << std::endl;
total += res;
std::cout << "short inner_product fusion test " << time_for_fusion_inner_product<8>(res) << std::endl;
total += res;
std::cout << "short inner_product fusion 2 test " << time_for_fusion_inner_product2<8>(res) << std::endl;
total += res;
std::cout << "medium inner_product std test " << time_for_std_inner_product<64>(res) << std::endl;
total += res;
std::cout << "medium inner_product fusion test " << time_for_fusion_inner_product<64>(res) << std::endl;
total += res;
std::cout << "medium inner_product fusion 2 test " << time_for_fusion_inner_product2<64>(res) << std::endl;
total += res;
std::cout << "long inner_product std test " << time_for_std_inner_product<128>(res) << std::endl;
total += res;
std::cout << "long inner_product fusion test " << time_for_fusion_inner_product<128>(res) << std::endl;
total += res;
std::cout << "long inner_product fusion 2 test " << time_for_fusion_inner_product2<128>(res) << std::endl;
total += res;
#endif
return total;
}

View File

@ -1,307 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
==============================================================================*/
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/functional/adapter/unfused.hpp>
#include <boost/fusion/functional/adapter/fused_function_object.hpp>
#include <boost/functional/forward_adapter.hpp>
#include <boost/functional/lightweight_forward_adapter.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/config.hpp>
#include <boost/timer.hpp>
#include <algorithm>
#include <iostream>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
int const REPEAT_COUNT = 3;
double const duration = 0.125;
namespace
{
struct fused_sum
{
template <typename Seq>
int operator()(Seq const & seq) const
{
int state = 0;
return boost::fusion::fold(seq, state, sum_op());
}
typedef int result_type;
private:
struct sum_op
{
template <typename T>
int operator()(T const & elem, int value) const
{
return value + sizeof(T) * elem;
}
template <typename T>
int operator()(T & elem, int value) const
{
elem += sizeof(T);
return value;
}
typedef int result_type;
};
};
struct unfused_sum
{
inline int operator()() const
{
return 0;
}
template<typename T0>
inline int operator()(T0 const & a0) const
{
return a0;
}
template<typename T0, typename T1>
inline int operator()(T0 const & a0, T1 const & a1) const
{
return a0 + a1;
}
template<typename T0, typename T1, typename T2>
inline int operator()(T0 const & a0, T1 const & a1, T2 a2) const
{
return a0 + a1 + a2;
}
template<typename T0, typename T1, typename T2, typename T3>
inline int operator()(T0 const & a0, T1 const & a1, T2 const & a2, T3 const & a3) const
{
return a0 + a1 + a2 + a3;
}
typedef int result_type;
};
template<typename F>
double call_unfused(F const & func, int & j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i += func();
i += func(0);
i += func(0,1);
i += func(0,1,2);
i += func(0,1,2,3);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = func(); j += i;
i = func(0); j += i;
i = func(0,1); j += i;
i = func(0,1,2); j += i;
i = func(0,1,2,3); j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
return result / iter;
}
template<typename F>
double call_fused_ra(F const & func, int & j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
do
{
boost::fusion::vector<> v0;
boost::fusion::vector<int> v1(0);
boost::fusion::vector<int,int> v2(0,1);
boost::fusion::vector<int,int,int> v3(0,1,2);
boost::fusion::vector<int,int,int,int> v4(0,1,2,3);
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i += func(v0);
i += func(v1);
i += func(v2);
i += func(v3);
i += func(v4);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
boost::fusion::vector<> v0;
boost::fusion::vector<int> v1(0);
boost::fusion::vector<int,int> v2(0,1);
boost::fusion::vector<int,int,int> v3(0,1,2);
boost::fusion::vector<int,int,int,int> v4(0,1,2,3);
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = func(v0); j += i;
i = func(v1); j += i;
i = func(v2); j += i;
i = func(v3); j += i;
i = func(v4); j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
return result / iter;
}
template<typename F>
double call_fused(F const & func, int & j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
do
{
boost::fusion::list<> l0;
boost::fusion::list<int> l1(0);
boost::fusion::list<int,int> l2(0,1);
boost::fusion::list<int,int,int> l3(0,1,2);
boost::fusion::list<int,int,int,int> l4(0,1,2,3);
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i += func(l0);
i += func(l1);
i += func(l2);
i += func(l3);
i += func(l4);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
boost::fusion::list<> l0;
boost::fusion::list<int> l1(0);
boost::fusion::list<int,int> l2(0,1);
boost::fusion::list<int,int,int> l3(0,1,2);
boost::fusion::list<int,int,int,int> l4(0,1,2,3);
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = func(l0); j += i;
i = func(l1); j += i;
i = func(l2); j += i;
i = func(l3); j += i;
i = func(l4); j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
return result / iter;
}
}
int main()
{
int total = 0;
int res;
typedef fused_sum F;
typedef unfused_sum U;
std::cout << "Compiler: " << BOOST_COMPILER << std::endl;
std::cout << std::endl << "Unfused adapters:" << std::endl;
{
F f;
std::cout << "F /* a fused function object */ " << call_fused_ra(f,res) << std::endl;
total += res;
}
{
F f;
std::cout << "without random access " << call_fused(f,res) << std::endl;
total += res;
}
{
boost::lightweight_forward_adapter< boost::fusion::unfused<F> > f;
std::cout << "lightweight_forward_adapter< unfused<F> > " << call_unfused(f,res) << std::endl;
total += res;
}
{
boost::forward_adapter< boost::fusion::unfused<F> > f;
std::cout << "forward_adapter< unfused<F> > " << call_unfused(f,res) << std::endl;
total += res;
}
std::cout << std::endl << "Fused adapters:" << std::endl;
{
unfused_sum f;
std::cout << "U /* an unfused function object */ " << call_unfused(f,res) << std::endl;
total += res;
}
{
boost::fusion::fused_function_object<U> f;
std::cout << "fused_function_object<U> " << call_fused_ra(f,res) << std::endl;
total += res;
}
{
boost::fusion::fused_function_object<U> f;
std::cout << "without random access " << call_fused(f,res) << std::endl;
total += res;
}
{
boost::lightweight_forward_adapter< boost::fusion::unfused< boost::fusion::fused_function_object<U> > > f;
std::cout << "lightweight_forward_adapter< unfused<fused_function_object<U> > >" << call_unfused(f,res) << std::endl;
total += res;
}
{
boost::forward_adapter< boost::fusion::unfused< boost::fusion::fused_function_object<U> > > f;
std::cout << "forward_adapter< unfused<fused_function_object<U> > > " << call_unfused(f,res) << std::endl;
total += res;
}
return total;
}

View File

@ -1,184 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/array.hpp>
#include <boost/timer.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/adapted/array.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <cmath>
#include <limits>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
int const REPEAT_COUNT = 10;
double const duration = 0.5;
namespace
{
struct poly_add
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_add(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + rhs;
}
};
struct poly_mult
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_mult(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs * rhs;
}
};
template<int N>
double time_for_std_inner_product(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
template<int N>
double time_for_fusion_inner_product(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::transform(arr1, arr2, poly_mult()), 0, poly_add());
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::transform(arr1, arr2, poly_mult()), 0, poly_add());
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
}
int main()
{
int total = 0;
int res;
std::cout << "short inner_product std test " << time_for_std_inner_product<8>(res) << std::endl;
total += res;
std::cout << "short inner_product fusion test " << time_for_fusion_inner_product<8>(res) << std::endl;
total += res;
std::cout << "medium inner_product std test " << time_for_std_inner_product<64>(res) << std::endl;
total += res;
std::cout << "medium inner_product fusion test " << time_for_fusion_inner_product<64>(res) << std::endl;
total += res;
std::cout << "long inner_product std test " << time_for_std_inner_product<128>(res) << std::endl;
total += res;
std::cout << "long inner_product fusion test " << time_for_fusion_inner_product<128>(res) << std::endl;
total += res;
return total;
}

View File

@ -1,206 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/array.hpp>
#include <boost/timer.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/adapted/array.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <cmath>
#include <limits>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
int const REPEAT_COUNT = 10;
double const duration = 0.5;
namespace
{
struct poly_add
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_add(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + rhs;
}
};
struct poly_mult
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_mult(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs * rhs;
}
};
template<int N>
double time_for_std_inner_product(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = std::inner_product(arr1.begin(), arr1.end(), arr2.begin(), 0);
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
struct poly_combine
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_combine(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
typename result<poly_combine(Lhs,Rhs)>::type
operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + boost::fusion::at_c<0>(rhs) * boost::fusion::at_c<1>(rhs);
}
};
template<int N>
double time_for_fusion_inner_product2(int& j)
{
boost::timer tim;
int i = 0;
long long iter = 65536;
long long counter, repeats;
double result = (std::numeric_limits<double>::max)();
double runtime = 0;
double run;
boost::array<int, N> arr1;
boost::array<int, N> arr2;
std::generate(arr1.begin(), arr1.end(), rand);
std::generate(arr2.begin(), arr2.end(), rand);
do
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::zip(arr1, arr2), 0, poly_combine());
static_cast<void>(i);
}
runtime = tim.elapsed();
iter *= 2;
} while(runtime < duration);
iter /= 2;
std::cout << iter << " iterations" << std::endl;
// repeat test and report least value for consistency:
for(repeats = 0; repeats < REPEAT_COUNT; ++repeats)
{
tim.restart();
for(counter = 0; counter < iter; ++counter)
{
i = boost::fusion::accumulate(
boost::fusion::zip(arr1, arr2), 0, poly_combine());
j += i;
}
run = tim.elapsed();
result = (std::min)(run, result);
}
std::cout << i << std::endl;
return result / iter;
}
}
int main()
{
int total = 0;
int res;
std::cout << "short inner_product std test " << time_for_std_inner_product<8>(res) << std::endl;
total += res;
std::cout << "short inner_product fusion 2 test " << time_for_fusion_inner_product2<8>(res) << std::endl;
total += res;
std::cout << "medium inner_product std test " << time_for_std_inner_product<64>(res) << std::endl;
total += res;
std::cout << "medium inner_product fusion 2 test " << time_for_fusion_inner_product2<64>(res) << std::endl;
total += res;
#if 0 // Leads to ICE with MSVC 8.0
std::cout << "long inner_product std test " << time_for_std_inner_product<128>(res) << std::endl;
total += res;
std::cout << "long inner_product fusion 2 test " << time_for_fusion_inner_product2<128>(res) << std::endl;
total += res;
#endif
return total;
}

View File

@ -1,85 +0,0 @@
// Copyright David Abrahams, Matthias Troyer, Michael Gauckler
// 2005. Distributed under the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(LIVE_CODE_TYPE)
# define LIVE_CODE_TYPE int
#endif
#include <boost/timer.hpp>
namespace test
{
// This value is required to ensure that a smart compiler's dead
// code elimination doesn't optimize away anything we're testing.
// We'll use it to compute the return code of the executable to make
// sure it's needed.
LIVE_CODE_TYPE live_code;
// Call objects of the given Accumulator type repeatedly with x as
// an argument.
template <class Accumulator, class Arg>
void hammer(Arg const& x, long const repeats)
{
// Strategy: because the sum in an accumulator after each call
// depends on the previous value of the sum, the CPU's pipeline
// might be stalled while waiting for the previous addition to
// complete. Therefore, we allocate an array of accumulators,
// and update them in sequence, so that there's no dependency
// between adjacent addition operations.
//
// Additionally, if there were only one accumulator, the
// compiler or CPU might decide to update the value in a
// register rather that writing it back to memory. we want each
// operation to at least update the L1 cache. *** Note: This
// concern is specific to the particular application at which
// we're targeting the test. ***
// This has to be at least as large as the number of
// simultaneous accumulations that can be executing in the
// compiler pipeline. A safe number here is larger than the
// machine's maximum pipeline depth. If you want to test the L2
// or L3 cache, or main memory, you can increase the size of
// this array. 1024 is an upper limit on the pipeline depth of
// current vector machines.
const std::size_t number_of_accumulators = 1024;
live_code = 0; // reset to zero
Accumulator a[number_of_accumulators];
for (long iteration = 0; iteration < repeats; ++iteration)
{
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
{
(*ap)(x);
}
}
// Accumulate all the partial sums to avoid dead code
// elimination.
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
{
live_code += ap->sum;
}
}
// Measure the time required to hammer accumulators of the given
// type with the argument x.
template <class Accumulator, class T>
double measure(T const& x, long const repeats)
{
// Hammer accumulators a couple of times to ensure the
// instruction cache is full of our test code, and that we don't
// measure the cost of a page fault for accessing the data page
// containing the memory where the accumulators will be
// allocated
hammer<Accumulator>(x, repeats);
hammer<Accumulator>(x, repeats);
// Now start a timer
boost::timer time;
hammer<Accumulator>(x, repeats); // This time, we'll measure
return time.elapsed() / repeats; // return the time of one iteration
}
}

View File

@ -1,248 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include "measure.hpp"
#define FUSION_MAX_LIST_SIZE 30
#define FUSION_MAX_VECTOR_SIZE 30
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/enum.hpp>
#include <iostream>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
// About the tests:
//
// The tests below compare various fusion sequences to see how abstraction
// affects prformance.
//
// We have 3 sequence sizes for each fusion sequence we're going to test.
//
// small = 3 elements
// medium = 10 elements
// big = 30 elements
//
// The sequences are initialized with values 0..N-1 from numeric strings
// parsed by boost::lexical_cast to make sure that the compiler is not
// optimizing by replacing the computation with constant results computed
// at compile time.
//
// These sequences will be subjected to our accumulator which calls
// fusion::accumulate:
//
// this->sum += boost::fusion::accumulate(seq, 0, poly_add());
//
// where poly_add simply sums the current value with the content of
// the sequence element. This accumulator will be called many times
// through the "hammer" test (see measure.hpp).
//
// The tests are compared against a base using a plain_accumulator
// which does a simple addition:
//
// this->sum += x;
namespace
{
struct poly_add
{
template<typename Sig>
struct result;
template<typename Lhs, typename Rhs>
struct result<poly_add(Lhs, Rhs)>
: boost::remove_reference<Lhs>
{};
template<typename Lhs, typename Rhs>
Lhs operator()(const Lhs& lhs, const Rhs& rhs) const
{
return lhs + rhs;
}
};
// Our Accumulator function
template <typename T>
struct accumulator
{
accumulator()
: sum()
{}
template <typename Sequence>
void operator()(Sequence const& seq)
{
this->sum += boost::fusion::accumulate(seq, 0, poly_add());
}
T sum;
};
// Plain Accumulator function
template <typename T>
struct plain_accumulator
{
plain_accumulator()
: sum()
{}
template <typename X>
void operator()(X const& x)
{
this->sum += x;
}
T sum;
};
template <typename T>
void check(T const& seq, char const* info)
{
test::measure<accumulator<int> >(seq, 1);
std::cout << info << test::live_code << std::endl;
}
template <typename T>
void measure(T const& seq, char const* info, long const repeats, double base)
{
double t = test::measure<accumulator<int> >(seq, repeats);
std::cout
<< info
<< t
<< " (" << int((t/base)*100) << "%)"
<< std::endl;
}
template <typename T>
void test_assembler(T const& seq)
{
test::live_code = boost::fusion::accumulate(seq, 0, poly_add());
}
}
// We'll initialize the sequences from numeric strings that
// pass through boost::lexical_cast to make sure that the
// compiler is not optimizing by replacing the computation
// with constant results computed at compile time.
#define INIT(z, n, text) boost::lexical_cast<int>(BOOST_PP_STRINGIZE(n))
int main()
{
using namespace boost::fusion;
std::cout.setf(std::ios::scientific);
vector<
int, int, int
>
vsmall(BOOST_PP_ENUM(3, INIT, _));
list<
int, int, int
>
lsmall(BOOST_PP_ENUM(3, INIT, _));
vector<
int, int, int, int, int, int, int, int, int, int
>
vmedium(BOOST_PP_ENUM(10, INIT, _));
list<
int, int, int, int, int, int, int, int, int, int
>
lmedium(BOOST_PP_ENUM(10, INIT, _));
vector<
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
>
vbig(BOOST_PP_ENUM(30, INIT, _));
list<
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
>
lbig(BOOST_PP_ENUM(30, INIT, _));
// first decide how many repetitions to measure
long repeats = 100;
double measured = 0;
while (measured < 2.0 && repeats <= 10000000)
{
repeats *= 10;
boost::timer time;
test::hammer<plain_accumulator<int> >(0, repeats);
test::hammer<accumulator<int> >(vsmall, repeats);
test::hammer<accumulator<int> >(lsmall, repeats);
test::hammer<accumulator<int> >(vmedium, repeats);
test::hammer<accumulator<int> >(lmedium, repeats);
test::hammer<accumulator<int> >(vbig, repeats);
test::hammer<accumulator<int> >(lbig, repeats);
measured = time.elapsed();
}
test::measure<plain_accumulator<int> >(1, 1);
std::cout
<< "base accumulated result: "
<< test::live_code
<< std::endl;
double base_time = test::measure<plain_accumulator<int> >(1, repeats);
std::cout
<< "base time: "
<< base_time;
std::cout
<< std::endl
<< "-------------------------------------------------------------------"
<< std::endl;
check(vsmall, "small vector accumulated result: ");
check(lsmall, "small list accumulated result: ");
check(vmedium, "medium vector accumulated result: ");
check(lmedium, "medium list accumulated result: ");
check(vbig, "big vector accumulated result: ");
check(lbig, "big list accumulated result: ");
std::cout
<< "-------------------------------------------------------------------"
<< std::endl;
measure(vsmall, "small vector time: ", repeats, base_time);
measure(lsmall, "small list time: ", repeats, base_time);
measure(vmedium, "medium vector time: ", repeats, base_time);
measure(lmedium, "medium list time: ", repeats, base_time);
measure(vbig, "big vector time: ", repeats, base_time);
measure(lbig, "big list time: ", repeats, base_time);
std::cout
<< "-------------------------------------------------------------------"
<< std::endl;
// Let's see how this looks in assembler
test_assembler(vmedium);
// This is ultimately responsible for preventing all the test code
// from being optimized away. Change this to return 0 and you
// unplug the whole test's life support system.
return test::live_code != 0;
}

View File

@ -1,57 +0,0 @@
===============================================================================
Copyright (C) 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger
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)
===============================================================================
Timing result for sequence_efficiency.cpp comparing the speed of various
fusion sequences. The test involves accumulating the elements of the
sequence which is primed to have values 0..N (N=size of sequence). Small,
medium and big sequences are tested where:
small = 3 elements
medium = 10 elements
big = 30 elements
Tester: Joel de Guzman. WinXP, P4-3.0GHZ, 2GB RAM
VC7.1 (flags = /MD /O2 /EHsc /GS)
small vector time: 1.870000e-006
small list time: 1.870000e-006
medium vector time: 1.880000e-006
medium list time: 3.600000e-006
big vector time: 2.030000e-006
big list time: 8.910000e-006
VC8.0 (flags = /MD /O2 /EHsc /GS)
small vector time: 2.500000e-05
small list time: 2.500000e-05
medium vector time: 7.810000e-05
medium list time: 7.810000e-05
big vector time: 2.469000e-04
big list time: 2.453000e-04
G++ 3.4 (flags = -ftemplate-depth-128 -funroll-loops -O3 -finline-functions -Wno-inline -Wall)
small vector time: 2.500000e-05
small list time: 2.500000e-05
medium vector time: 7.970000e-05
medium list time: 7.970000e-05
big vector time: 2.516000e-04
big list time: 2.485000e-04
Intel 9.1 (flags = /MD /O2 /EHsc /GS)
small vector time: 1.125000e-006
small list time: 1.125000e-006
medium vector time: 1.125000e-006
medium list time: 1.141000e-006
big vector time: 1.140000e-006
big list time: 1.141000e-006

View File

@ -1,155 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include "measure.hpp"
//~ #define FUSION_MAX_VECTOR_SIZE 30
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <iostream>
#ifdef _MSC_VER
// inline aggressively
# pragma inline_recursion(on) // turn on inline recursion
# pragma inline_depth(255) // max inline depth
#endif
namespace
{
struct zip_add
{
template<typename Lhs, typename Rhs>
struct result
{
typedef typename
boost::remove_reference<
typename boost::fusion::result_of::value_at_c<Lhs, 0>::type
>::type
type;
};
template<typename Lhs, typename Rhs>
typename result<Lhs, Rhs>::type
operator()(const Lhs& lhs, const Rhs& rhs) const
{
return boost::fusion::at_c<0>(lhs) + boost::fusion::at_c<1>(lhs) + rhs;
}
};
// Our Accumulator function
template <typename T>
struct zip_accumulator
{
zip_accumulator()
: sum()
{}
template <typename Sequence>
void operator()(Sequence const& seq)
{
this->sum += boost::fusion::accumulate(seq, 0, zip_add());
}
T sum;
};
template <typename T>
void check(T const& seq, char const* info)
{
test::measure<zip_accumulator<int> >(seq, 1);
std::cout << info << test::live_code << std::endl;
}
template <typename T>
void measure(T const& seq, char const* info, long const repeats)
{
std::cout
<< info
<< test::measure<zip_accumulator<int> >(seq, repeats)
<< std::endl;
}
}
int main()
{
using namespace boost::fusion;
std::cout.setf(std::ios::scientific);
vector<
int, int, int
>
vsmall_1(BOOST_PP_ENUM_PARAMS(3,));
vector<
int, int, int
>
vsmall_2(BOOST_PP_ENUM_PARAMS(3,));
vector<
int, int, int, int, int, int, int, int, int, int
>
vmedium_1(BOOST_PP_ENUM_PARAMS(10,));
vector<
int, int, int, int, int, int, int, int, int, int
>
vmedium_2(BOOST_PP_ENUM_PARAMS(10,));
//~ vector<
//~ 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
//~ >
//~ vbig_1(BOOST_PP_ENUM_PARAMS(30,));
//~ vector<
//~ 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
//~ >
//~ vbig_2(BOOST_PP_ENUM_PARAMS(30,));
// first decide how many repetitions to measure
long repeats = 100;
double measured = 0;
while (measured < 2.0 && repeats <= 10000000)
{
repeats *= 10;
boost::timer time;
test::hammer<zip_accumulator<int> >(zip(vsmall_1, vsmall_2), repeats);
test::hammer<zip_accumulator<int> >(zip(vmedium_1, vmedium_2), repeats);
//~ test::hammer<zip_accumulator<int> >(zip(vbig_1, vbig_2), repeats);
measured = time.elapsed();
}
check(zip(vsmall_1, vsmall_2),
"small zip accumulated result: ");
check(zip(vmedium_1, vmedium_2),
"medium zip accumulated result: ");
//~ check(zip(vbig_1, vbig_2),
//~ "big zip accumulated result: ");
measure(zip(vsmall_1, vsmall_2),
"small zip time: ", repeats);
measure(zip(vmedium_1, vmedium_2),
"medium zip time: ", repeats);
//~ measure(zip(vbig_1, vbig_2),
//~ "big zip time: ", repeats);
// This is ultimately responsible for preventing all the test code
// from being optimized away. Change this to return 0 and you
// unplug the whole test's life support system.
return test::live_code != 0;
}

View File

@ -1,26 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ADAPTED_30122005_1420)
#define BOOST_FUSION_ADAPTED_30122005_1420
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/adt.hpp>
#include <boost/fusion/adapted/array.hpp>
#include <boost/fusion/adapted/boost_array.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/adapted/std_pair.hpp>
#include <boost/fusion/adapted/struct.hpp>
// The std_tuple_iterator adaptor only supports implementations
// using variadic templates
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/fusion/adapted/std_tuple.hpp>
#endif
#endif

View File

@ -1,19 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_HPP
#define BOOST_FUSION_ADAPTED_ADT_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt_named.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/fusion/adapted/adt/adapt_adt_named.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
#endif

View File

@ -1,80 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2009-2010 Hartmut Kaiser
Copyright (c) 2010-2011 Christopher Schmidt
Copyright (c) 2013-2014 Damien Buhl
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_HPP
#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/comparison/less.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/adapted/struct/detail/extension.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_base.hpp>
#include <boost/fusion/adapted/struct/detail/at_impl.hpp>
#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/struct/detail/proxy_type.hpp>
#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/size_impl.hpp>
#include <boost/fusion/adapted/struct/detail/begin_impl.hpp>
#include <boost/fusion/adapted/struct/detail/end_impl.hpp>
#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/deref_impl.hpp>
#include <boost/fusion/adapted/adt/detail/extension.hpp>
#include <boost/fusion/adapted/adt/detail/adapt_base.hpp>
#include <boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp>
#define BOOST_FUSION_ADAPT_ADT_C( \
TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \
BOOST_FUSION_ADAPT_ADT_C_BASE( \
TEMPLATE_PARAMS_SEQ, \
NAME_SEQ, \
I, \
BOOST_PP_IIF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE), \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \
BOOST_PP_LESS( \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), 4)) \
#define BOOST_FUSION_ADAPT_TPL_ADT(TEMPLATE_PARAMS_SEQ, NAME_SEQ , ATTRIBUTES) \
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(1)TEMPLATE_PARAMS_SEQ, \
(1)NAME_SEQ, \
struct_tag, \
0, \
BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ADT_C)
#define BOOST_FUSION_ADAPT_ADT(NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(0), \
(0)(NAME), \
struct_tag, \
0, \
BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ADT_C)
#define BOOST_FUSION_ADAPT_ADT_AS_VIEW(NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(0), \
(0)(NAME), \
struct_tag, \
1, \
BOOST_PP_CAT(BOOST_FUSION_ADAPT_ADT_FILLER_0(0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ADT_C)
#endif

View File

@ -1,31 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2009-2010 Hartmut Kaiser
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_NAMED_HPP
#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ADT_NAMED_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/adt/adapt_adt.hpp>
#include <boost/fusion/adapted/struct/detail/proxy_type.hpp>
#define BOOST_FUSION_ADAPT_ADT_NAMED_NS( \
WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \
\
BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \
WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \
\
BOOST_FUSION_ADAPT_ADT_AS_VIEW( \
BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \
ATTRIBUTES)
#define BOOST_FUSION_ADAPT_ADT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_ADT_NAMED_NS( \
WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES)
#endif

View File

@ -1,95 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2007 Dan Marsden
Copyright (c) 2010-2011 Christopher Schmidt
Copyright (c) 2013-2014 Damien Buhl
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_HPP
#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/fusion/adapted/struct/detail/extension.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_base.hpp>
#include <boost/fusion/adapted/struct/detail/at_impl.hpp>
#include <boost/fusion/adapted/struct/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/struct/detail/proxy_type.hpp>
#include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/struct/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/struct/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/size_impl.hpp>
#include <boost/fusion/adapted/struct/detail/begin_impl.hpp>
#include <boost/fusion/adapted/struct/detail/end_impl.hpp>
#include <boost/fusion/adapted/struct/detail/value_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/deref_impl.hpp>
#include <boost/fusion/adapted/struct/detail/deref_data_impl.hpp>
#include <boost/fusion/adapted/struct/detail/key_of_impl.hpp>
#include <boost/fusion/adapted/struct/detail/value_of_data_impl.hpp>
#include <boost/fusion/adapted/adt/detail/extension.hpp>
#include <boost/fusion/adapted/adt/detail/adapt_base.hpp>
#include <boost/fusion/adapted/adt/detail/adapt_base_assoc_attr_filler.hpp>
#define BOOST_FUSION_ADAPT_ASSOC_ADT_C( \
TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \
\
BOOST_FUSION_ADAPT_ADT_C_BASE( \
TEMPLATE_PARAMS_SEQ, \
NAME_SEQ, \
I, \
BOOST_PP_IIF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE), \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \
BOOST_PP_LESS( \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), 5)) \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
struct struct_assoc_key<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ), I> \
{ \
typedef BOOST_FUSION_ADAPT_ASSOC_ADT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) type;\
};
#define BOOST_FUSION_ADAPT_ASSOC_TPL_ADT( \
TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \
\
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(1)TEMPLATE_PARAMS_SEQ, \
(1)NAME_SEQ, \
assoc_struct_tag, \
0, \
BOOST_PP_CAT( \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ASSOC_ADT_C)
#define BOOST_FUSION_ADAPT_ASSOC_ADT(NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(0), \
(0)(NAME), \
assoc_struct_tag, \
0, \
BOOST_PP_CAT( \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ASSOC_ADT_C)
#define BOOST_FUSION_ADAPT_ASSOC_ADT_AS_VIEW(NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_STRUCT_BASE( \
(0), \
(0)(NAME), \
assoc_struct_tag, \
1, \
BOOST_PP_CAT( \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(0,0,0,0,0)ATTRIBUTES,_END), \
BOOST_FUSION_ADAPT_ASSOC_ADT_C)
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_NAMED_HPP
#define BOOST_FUSION_ADAPTED_ADT_ADAPT_ASSOC_ADT_NAMED_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/adt/adapt_assoc_adt.hpp>
#include <boost/fusion/adapted/struct/detail/proxy_type.hpp>
#define BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED_NS( \
WRAPPED_TYPE, NAMESPACE_SEQ, NAME, ATTRIBUTES) \
\
BOOST_FUSION_ADAPT_STRUCT_DEFINE_PROXY_TYPE_IMPL( \
WRAPPED_TYPE,(0)NAMESPACE_SEQ,NAME) \
\
BOOST_FUSION_ADAPT_ASSOC_ADT_AS_VIEW( \
BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DECLARATION((0)NAMESPACE_SEQ)NAME, \
ATTRIBUTES)
#define BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED(WRAPPED_TYPE, NAME, ATTRIBUTES) \
BOOST_FUSION_ADAPT_ASSOC_ADT_NAMED_NS( \
WRAPPED_TYPE,(boost)(fusion)(adapted),NAME,ATTRIBUTES)
#endif

View File

@ -1,301 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP
#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/control/expr_if.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#include <boost/preprocessor/seq/elem.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/typeof/typeof.hpp>
#define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL(TEMPLATE_PARAMS_SEQ) \
typename detail::get_identity< \
lvalue \
, BOOST_PP_SEQ_ELEM(1,TEMPLATE_PARAMS_SEQ) \
>::type
#define BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_NON_TEMPLATE_IMPL( \
TEMPLATE_PARAMS_SEQ) \
\
boost::remove_const<boost::remove_reference<lvalue>::type>::type
#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE) \
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, \
BOOST_PP_IF(DEDUCE_TYPE, 0, 2), ATTRIBUTE)
#define BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE) \
BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, \
BOOST_PP_IF(DEDUCE_TYPE, 1, 3), ATTRIBUTE)
#ifdef BOOST_MSVC
# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
\
BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
TEMPLATE_PARAMS_SEQ) \
\
struct deduced_attr_type { \
static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
typedef \
BOOST_PP_EXPR_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), \
typename) \
BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \
ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, 1)) type; \
};
#else
# define BOOST_FUSION_DEDUCED_ATTR_TYPE(NAME_SEQ, ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
struct deduced_attr_type { \
static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
typedef BOOST_TYPEOF( PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR( \
ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, 1)) type; \
};
#endif
#define BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF( \
NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
\
BOOST_FUSION_DEDUCED_ATTR_TYPE( \
NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
\
typedef \
BOOST_PP_EXPR_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), \
typename) \
boost::remove_const< \
BOOST_PP_EXPR_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), \
typename) \
deduced_attr_type::type \
>::type type; \
\
typedef \
BOOST_PP_EXPR_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), \
typename) \
boost::add_const< \
BOOST_PP_EXPR_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), \
typename) \
deduced_attr_type::type \
>::type const_type;
#define BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE( \
NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
\
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, 0, ATTRIBUTE) type; \
typedef BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, 1, ATTRIBUTE) const_type;
#define BOOST_FUSION_ADAPT_ADT_C_BASE( \
TEMPLATE_PARAMS_SEQ,NAME_SEQ,I,PREFIX, \
ATTRIBUTE,ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE) \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
struct access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
> \
{ \
\
BOOST_PP_IF(DEDUCE_TYPE, \
BOOST_FUSION_ADT_ATTRIBUTE_TYPEOF, \
BOOST_FUSION_ADT_ATTRIBUTE_GIVENTYPE)( \
NAME_SEQ, \
ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, \
PREFIX, \
TEMPLATE_PARAMS_SEQ) \
\
template<class Val> \
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
static void \
boost_fusion_adapt_adt_impl_set( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj, \
Val const& val) \
{ \
PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_SETEXPR(ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE); \
} \
\
BOOST_FUSION_GPU_ENABLED \
static type \
boost_fusion_adapt_adt_impl_get( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj) \
{ \
return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE); \
} \
\
BOOST_FUSION_GPU_ENABLED \
static const_type \
boost_fusion_adapt_adt_impl_get( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& obj) \
{ \
return PREFIX() BOOST_FUSION_ADAPT_ADT_ATTRIBUTE_GETEXPR(ATTRIBUTE, \
ATTRIBUTE_TUPLE_SIZE, DEDUCE_TYPE); \
} \
}; \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
struct adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, true \
> \
{ \
typedef \
BOOST_PP_EXPR_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename) \
access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
>::const_type type; \
\
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
explicit \
adt_attribute_proxy( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const& o) \
: obj(&o) \
{} \
\
BOOST_FUSION_GPU_ENABLED \
type get() const \
{ \
return access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
>::boost_fusion_adapt_adt_impl_get(*obj); \
} \
\
BOOST_FUSION_GPU_ENABLED \
operator type() const \
{ \
return get(); \
} \
\
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const* obj; \
}; \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
struct adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, false \
> \
{ \
typedef \
BOOST_PP_EXPR_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), typename) \
access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
>::type type; \
\
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
explicit \
adt_attribute_proxy( \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& o) \
: obj(&o) \
{} \
\
template<class Val> \
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
adt_attribute_proxy& \
operator=(Val const& val) \
{ \
access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
>::boost_fusion_adapt_adt_impl_set(*obj, val); \
return *this; \
} \
\
BOOST_FUSION_GPU_ENABLED \
type get() const \
{ \
return access::adt_attribute_access< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
>::boost_fusion_adapt_adt_impl_get(*obj); \
} \
\
BOOST_FUSION_GPU_ENABLED \
operator type() const \
{ \
return get(); \
} \
\
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)* obj; \
}; \
\
template< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
> \
struct access::struct_member< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
> \
{ \
typedef BOOST_PP_EXPR_IF(BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), \
typename) \
adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, false \
>::type lvalue; \
\
BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
TEMPLATE_PARAMS_SEQ) \
\
typedef \
BOOST_PP_IF( \
BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ), \
BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_TEMPLATE_IMPL, \
BOOST_FUSION_ADAPT_ADT_GET_IDENTITY_NON_TEMPLATE_IMPL)( \
TEMPLATE_PARAMS_SEQ) \
type; \
\
template<typename Seq> \
struct apply \
{ \
typedef \
adt_attribute_proxy< \
BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
, I \
, is_const<Seq>::value \
> \
type; \
\
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
static type \
call(Seq& obj) \
{ \
return type(obj); \
} \
}; \
};
#endif

View File

@ -1,64 +0,0 @@
/*=============================================================================
Copyright (c) 2013-2014 Damien Buhl
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTER_ADT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP
#define BOOST_FUSION_ADAPTER_ADT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP
#include <boost/config.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
#include <boost/fusion/adapted/adt/detail/adapt_base_attr_filler.hpp>
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
#include <boost/preprocessor/config/config.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/variadic/size.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#if BOOST_PP_VARIADICS
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(...) \
BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(__VA_ARGS__) \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1(...) \
BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(__VA_ARGS__) \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0
#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(...) \
((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__)))
#else // BOOST_PP_VARIADICS
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0(A, B, C, D, E) \
BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1(A, B, C, D, E) \
BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \
BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0
#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAP_ATTR(A, B, C, D, E) \
BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \
((3, (C,D,E))), \
((5, (A,B,C,D,E))) \
)
#endif // BOOST_PP_VARIADICS
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_0_END
#define BOOST_FUSION_ADAPT_ASSOC_ADT_FILLER_1_END
#define BOOST_FUSION_ADAPT_ASSOC_ADT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) \
BOOST_PP_TUPLE_ELEM( \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE), \
BOOST_PP_DEC(BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE)), \
BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE))
#endif

View File

@ -1,92 +0,0 @@
/*=============================================================================
Copyright (c) 2013-2014 Damien Buhl
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
#define BOOST_FUSION_ADAPTED_ADT_DETAIL_ADAPT_BASE_ATTR_FILLER_HPP
#include <boost/config.hpp>
#include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
#include <boost/fusion/adapted/struct/detail/preprocessor/is_seq.hpp>
#include <boost/mpl/aux_/preprocessor/token_equal.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/logical/or.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/variadic/size.hpp>
#include <boost/preprocessor/variadic/elem.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#include <boost/preprocessor/seq/rest_n.hpp>
#define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR_SIZE(ATTRIBUTE) \
BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE)
#define BOOST_FUSION_ADAPT_ADT_WRAPPEDATTR(ATTRIBUTE) \
BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE)
#if BOOST_PP_VARIADICS
# define BOOST_FUSION_ADAPT_ADT_FILLER_0(...) \
BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \
BOOST_FUSION_ADAPT_ADT_FILLER_1
# define BOOST_FUSION_ADAPT_ADT_FILLER_1(...) \
BOOST_FUSION_ADAPT_ADT_FILLER(__VA_ARGS__) \
BOOST_FUSION_ADAPT_ADT_FILLER_0
# define BOOST_FUSION_ADAPT_ADT_FILLER_0_END
# define BOOST_FUSION_ADAPT_ADT_FILLER_1_END
// MSVC don't compile when using BOOST_PP_BITOR instead of BOOST_PP_OR.
# define BOOST_FUSION_ADAPT_ADT_FILLER(...) \
BOOST_PP_IIF( \
BOOST_PP_OR( \
BOOST_MPL_PP_TOKEN_EQUAL(auto, \
BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)), \
BOOST_MPL_PP_TOKEN_EQUAL(auto, \
BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__))), \
\
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR( \
BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__), \
BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(__VA_ARGS__) \
), \
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(__VA_ARGS__))
# define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(...) \
((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__)))
# define BOOST_FUSION_WORKAROUND_VARIADIC_EMPTINESS_LAST_ELEM(...) \
BOOST_PP_SEQ_HEAD(BOOST_PP_SEQ_REST_N( \
BOOST_PP_DEC(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)), \
BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)))
#else // BOOST_PP_VARIADICS
# define BOOST_FUSION_ADAPT_ADT_FILLER_0(A, B, C, D) \
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \
BOOST_FUSION_ADAPT_ADT_FILLER_1
# define BOOST_FUSION_ADAPT_ADT_FILLER_1(A, B, C, D) \
BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A,B,C,D) \
BOOST_FUSION_ADAPT_ADT_FILLER_0
# define BOOST_FUSION_ADAPT_ADT_FILLER_0_END
# define BOOST_FUSION_ADAPT_ADT_FILLER_1_END
# define BOOST_FUSION_ADAPT_ADT_WRAP_ATTR(A, B, C, D) \
BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, A), \
((2, (C,D))), \
((4, (A,B,C,D))) \
)
#endif // BOOST_PP_VARIADICS
#endif

View File

@ -1,41 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ADT_DETAIL_EXTENSION_HPP
#define BOOST_FUSION_ADAPTED_ADT_DETAIL_EXTENSION_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/support/as_const.hpp>
#include <boost/fusion/adapted/struct/detail/extension.hpp>
namespace boost { namespace fusion
{
namespace detail
{
template <typename T, typename Dummy>
struct get_identity
: remove_const<typename remove_reference<T>::type>
{};
}
namespace extension
{
// Overload as_const() to unwrap adt_attribute_proxy.
template <typename T, int N, bool Const>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename adt_attribute_proxy<T, N, Const>::type as_const(const adt_attribute_proxy<T, N, Const>& proxy)
{
return proxy.get();
}
}
}}
#endif

View File

@ -1,27 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ARRAY_27122005_1035)
#define BOOST_FUSION_ARRAY_27122005_1035
//For backwards compatibility
#include <boost/fusion/adapted/boost_array.hpp>
#include <boost/fusion/adapted/array/tag_of.hpp>
#include <boost/fusion/adapted/array/is_view_impl.hpp>
#include <boost/fusion/adapted/array/is_sequence_impl.hpp>
#include <boost/fusion/adapted/array/category_of_impl.hpp>
#include <boost/fusion/adapted/array/begin_impl.hpp>
#include <boost/fusion/adapted/array/end_impl.hpp>
#include <boost/fusion/adapted/array/size_impl.hpp>
#include <boost/fusion/adapted/array/at_impl.hpp>
#include <boost/fusion/adapted/array/value_at_impl.hpp>
#include <boost/fusion/adapted/array/deref_impl.hpp>
#include <boost/fusion/adapted/array/value_of_impl.hpp>
#endif

View File

@ -1,40 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_AT_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_AT_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct at_impl;
template<>
struct at_impl<po_array_tag>
{
template<typename Seq, typename N>
struct apply
{
typedef typename
add_reference<typename remove_extent<Seq>::type>::type
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Seq& seq)
{
return seq[N::value];
}
};
};
}}}
#endif

View File

@ -1,44 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_BEGIN_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_BEGIN_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct begin_impl;
template <>
struct begin_impl<po_array_tag>
{
template <typename Seq>
struct apply
{
typedef
basic_iterator<
po_array_iterator_tag
, random_access_traversal_tag
, Seq
, 0
>
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Seq& seq)
{
return type(seq,0);
}
};
};
}}}
#endif

View File

@ -1,32 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_CATEGORY_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_CATEGORY_OF_IMPL_HPP
namespace boost { namespace fusion
{
struct random_access_traversal_tag;
namespace extension
{
template<typename>
struct category_of_impl;
template<>
struct category_of_impl<po_array_tag>
{
template<typename Seq>
struct apply
{
typedef random_access_traversal_tag type;
};
};
}
}}
#endif

View File

@ -1,42 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_DEREF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_DEREF_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_impl;
template <>
struct deref_impl<po_array_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
add_reference<
typename remove_extent<typename It::seq_type>::type
>::type
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(It const& it)
{
return (*it.seq)[It::index::value];
}
};
};
}}}
#endif

View File

@ -1,46 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_END_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_END_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/iterator/basic_iterator.hpp>
#include <boost/type_traits/rank.hpp>
#include <boost/type_traits/extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct end_impl;
template <>
struct end_impl<po_array_tag>
{
template <typename Seq>
struct apply
{
typedef
basic_iterator<
po_array_iterator_tag
, random_access_traversal_tag
, Seq
, extent<Seq,rank<Seq>::value-1>::value
>
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Seq& seq)
{
return type(seq,0);
}
};
};
}}}
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_IS_SEQUENCE_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_IS_SEQUENCE_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct is_sequence_impl;
template<>
struct is_sequence_impl<po_array_tag>
{
template<typename Seq>
struct apply
: mpl::true_
{};
};
}}}
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_IS_VIEW_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_IS_VIEW_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct is_view_impl;
template<>
struct is_view_impl<po_array_tag>
{
template<typename Seq>
struct apply
: mpl::false_
{};
};
}}}
#endif

View File

@ -1,30 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_SIZE_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_SIZE_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/rank.hpp>
#include <boost/type_traits/extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct size_impl;
template<>
struct size_impl<po_array_tag>
{
template<typename Seq>
struct apply
: extent<Seq,rank<Seq>::value-1>
{};
};
}}}
#endif

View File

@ -1,73 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_TAG_OF_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_TAG_OF_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <cstddef>
namespace boost
{
namespace fusion
{
struct po_array_tag;
struct po_array_iterator_tag;
struct random_access_traversal_tag;
struct fusion_sequence_tag;
namespace traits
{
#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
template<typename T, std::size_t N>
struct tag_of<T[N], void>
{
typedef po_array_tag type;
};
template<typename T, std::size_t N>
struct tag_of<T const[N], void>
{
typedef po_array_tag type;
};
#else
template<typename T, std::size_t N>
struct tag_of<T[N], void>
{
typedef po_array_tag type;
};
template<typename T, std::size_t N>
struct tag_of<T const[N], void>
{
typedef po_array_tag type;
};
#endif
}
}
namespace mpl
{
template<typename>
struct sequence_tag;
template<typename T, std::size_t N>
struct sequence_tag<T[N]>
{
typedef fusion::po_array_tag type;
};
template<typename T, std::size_t N>
struct sequence_tag<T const[N] >
{
typedef fusion::po_array_tag type;
};
}
}
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_VALUE_AT_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_VALUE_AT_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/remove_extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template<typename>
struct value_at_impl;
template <>
struct value_at_impl<po_array_tag>
{
template <typename Seq, typename N>
struct apply
: remove_extent<Seq>
{};
};
}}}
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2010 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_FUSION_ADAPTED_ARRAY_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_ADAPTED_ARRAY_VALUE_OF_IMPL_HPP
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/remove_extent.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_impl;
template <>
struct value_of_impl<po_array_iterator_tag>
{
template <typename It>
struct apply
: remove_extent<typename It::seq_type>
{};
};
}}}
#endif

View File

@ -1,23 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_BOOST_ARRAY_27122005_1035)
#define BOOST_FUSION_BOOST_ARRAY_27122005_1035
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/boost_array/array_iterator.hpp>
#include <boost/fusion/adapted/boost_array/tag_of.hpp>
#include <boost/fusion/adapted/boost_array/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/begin_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/end_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/size_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/at_impl.hpp>
#include <boost/fusion/adapted/boost_array/detail/value_at_impl.hpp>
#endif

View File

@ -1,121 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_ARRAY_ITERATOR_26122005_2250)
#define BOOST_FUSION_ARRAY_ITERATOR_26122005_2250
#include <boost/fusion/support/config.hpp>
#include <cstddef>
#include <boost/config.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp>
namespace boost { namespace fusion
{
struct random_access_traversal_tag;
template <typename Array, int Pos>
struct array_iterator
: iterator_facade<array_iterator<Array, Pos>, random_access_traversal_tag>
{
BOOST_MPL_ASSERT_RELATION(Pos, >=, 0);
BOOST_MPL_ASSERT_RELATION(Pos, <=, static_cast<int>(Array::static_size));
typedef mpl::int_<Pos> index;
typedef Array array_type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
array_iterator(Array& a)
: array(a) {}
Array& array;
template <typename Iterator>
struct value_of
{
typedef typename Iterator::array_type array_type;
typedef typename array_type::value_type type;
};
template <typename Iterator>
struct deref
{
typedef typename Iterator::array_type array_type;
typedef typename
mpl::if_<
is_const<array_type>
, typename array_type::const_reference
, typename array_type::reference
>::type
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Iterator const & it)
{
return it.array[Iterator::index::value];
}
};
template <typename Iterator, typename N>
struct advance
{
typedef typename Iterator::index index;
typedef typename Iterator::array_type array_type;
typedef array_iterator<array_type, index::value + N::value> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Iterator const& i)
{
return type(i.array);
}
};
template <typename Iterator>
struct next : advance<Iterator, mpl::int_<1> > {};
template <typename Iterator>
struct prior : advance<Iterator, mpl::int_<-1> > {};
template <typename I1, typename I2>
struct distance : mpl::minus<typename I2::index, typename I1::index>
{
typedef typename
mpl::minus<
typename I2::index, typename I1::index
>::type
type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(I1 const&, I2 const&)
{
return type();
}
};
private:
array_iterator<Array, Pos>& operator=(array_iterator<Array, Pos> const&);
};
}}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Array, int Pos>
struct iterator_traits< ::boost::fusion::array_iterator<Array, Pos> >
{ };
}
#endif
#endif

View File

@ -1,47 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_AT_IMPL_27122005_1241)
#define BOOST_FUSION_AT_IMPL_27122005_1241
#include <boost/fusion/support/config.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp>
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template<typename T>
struct at_impl;
template<>
struct at_impl<boost_array_tag>
{
template<typename Sequence, typename N>
struct apply
{
typedef typename mpl::if_<
is_const<Sequence>,
typename Sequence::const_reference,
typename Sequence::reference>::type type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Sequence& seq)
{
return seq[N::value];
}
};
};
}
}}
#endif

View File

@ -1,42 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_BEGIN_IMPL_27122005_1117)
#define BOOST_FUSION_BEGIN_IMPL_27122005_1117
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/boost_array/array_iterator.hpp>
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template<typename T>
struct begin_impl;
template <>
struct begin_impl<boost_array_tag>
{
template <typename Sequence>
struct apply
{
typedef array_iterator<Sequence, 0> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

View File

@ -1,36 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_27122005_1044)
#define BOOST_FUSION_CATEGORY_OF_IMPL_27122005_1044
#include <boost/fusion/support/config.hpp>
#include <boost/config/no_tr1/utility.hpp>
namespace boost { namespace fusion {
struct boost_array_tag;
struct random_access_traversal_tag;
namespace extension
{
template<typename T>
struct category_of_impl;
template<>
struct category_of_impl<boost_array_tag>
{
template<typename T>
struct apply
{
typedef random_access_traversal_tag type;
};
};
}
}}
#endif

View File

@ -1,42 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_END_IMPL_27122005_1120)
#define BOOST_FUSION_END_IMPL_27122005_1120
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/boost_array/array_iterator.hpp>
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<boost_array_tag>
{
template <typename Sequence>
struct apply
{
typedef array_iterator<Sequence, Sequence::static_size> type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

View File

@ -1,32 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1648)
#define BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1648
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template<typename Tag>
struct is_sequence_impl;
template<>
struct is_sequence_impl<boost_array_tag>
{
template<typename Sequence>
struct apply : mpl::true_ {};
};
}
}}
#endif

View File

@ -1,33 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_IS_VIEW_IMPL_27042006_2221)
#define BOOST_FUSION_IS_VIEW_IMPL_27042006_2221
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
{
struct boost_array_tag;
namespace extension
{
template<typename Tag>
struct is_view_impl;
template<>
struct is_view_impl<boost_array_tag>
{
template<typename T>
struct apply : mpl::false_
{};
};
}
}}
#endif

View File

@ -1,29 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_SIZE_IMPL_27122005_1251)
#define BOOST_FUSION_SIZE_IMPL_27122005_1251
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template<typename T>
struct size_impl;
template<>
struct size_impl<boost_array_tag>
{
template<typename Sequence>
struct apply : mpl::int_<Sequence::static_size> {};
};
}
}}
#endif

View File

@ -1,32 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_VALUE_AT_IMPL_27122005_1256)
#define BOOST_FUSION_VALUE_AT_IMPL_27122005_1256
namespace boost { namespace fusion {
struct boost_array_tag;
namespace extension
{
template<typename T>
struct value_at_impl;
template <>
struct value_at_impl<boost_array_tag>
{
template <typename Sequence, typename N>
struct apply
{
typedef typename Sequence::value_type type;
};
};
}
}}
#endif

View File

@ -1,59 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_SEQUENCE_TAG_OF_27122005_1030)
#define FUSION_SEQUENCE_TAG_OF_27122005_1030
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <cstddef>
namespace boost
{
template<typename T, std::size_t N>
class array;
}
namespace boost { namespace fusion
{
struct boost_array_tag;
struct fusion_sequence_tag;
namespace traits
{
template<typename T, std::size_t N>
#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS)
struct tag_of<boost::array<T,N>, void >
#else
struct tag_of<boost::array<T,N> >
#endif
{
typedef boost_array_tag type;
};
}
}}
namespace boost { namespace mpl
{
template<typename>
struct sequence_tag;
template<typename T, std::size_t N>
struct sequence_tag<array<T,N> >
{
typedef fusion::fusion_sequence_tag type;
};
template<typename T, std::size_t N>
struct sequence_tag<array<T,N> const>
{
typedef fusion::fusion_sequence_tag type;
};
}}
#endif

View File

@ -1,23 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_BOOST_TUPLE_09272006_0732)
#define BOOST_FUSION_BOOST_TUPLE_09272006_0732
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/boost_tuple/tag_of.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/end_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/size_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/at_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/detail/convert_impl.hpp>
#include <boost/fusion/adapted/boost_tuple/mpl/clear.hpp>
#endif

View File

@ -1,221 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_BOOST_TUPLE_ITERATOR_09262006_1851)
#define FUSION_BOOST_TUPLE_ITERATOR_09262006_1851
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/tuple/tuple.hpp>
namespace boost { namespace fusion
{
struct forward_traversal_tag;
namespace detail
{
template <typename T>
struct boost_tuple_is_empty : mpl::false_ {};
template <>
struct boost_tuple_is_empty<tuples::null_type> : mpl::true_ {};
template <>
struct boost_tuple_is_empty<tuples::null_type const> : mpl::true_ {};
template <>
struct boost_tuple_is_empty<tuples::tuple<> > : mpl::true_ {};
template <>
struct boost_tuple_is_empty<tuples::tuple<> const> : mpl::true_ {};
}
template <typename Cons>
struct boost_tuple_iterator_identity;
template <typename Cons = tuples::null_type>
struct boost_tuple_iterator
: iterator_facade<boost_tuple_iterator<Cons>, forward_traversal_tag>
{
typedef Cons cons_type;
typedef boost_tuple_iterator_identity<
typename add_const<Cons>::type> identity;
BOOST_FUSION_GPU_ENABLED
explicit boost_tuple_iterator(Cons& in_cons)
: cons(in_cons) {}
Cons& cons;
template <typename Iterator>
struct value_of : mpl::identity<typename Iterator::cons_type::head_type> {};
template <typename Iterator>
struct deref
{
typedef typename value_of<Iterator>::type element;
typedef typename
mpl::if_<
is_const<typename Iterator::cons_type>
, typename tuples::access_traits<element>::const_type
, typename tuples::access_traits<element>::non_const_type
>::type
type;
BOOST_FUSION_GPU_ENABLED
static type
call(Iterator const& iter)
{
return iter.cons.get_head();
}
};
template <typename Iterator>
struct next
{
typedef typename Iterator::cons_type cons_type;
typedef typename cons_type::tail_type tail_type;
typedef boost_tuple_iterator<
typename mpl::eval_if<
is_const<cons_type>
, add_const<tail_type>
, mpl::identity<tail_type>
>::type>
type;
BOOST_FUSION_GPU_ENABLED
static type
call(Iterator const& iter)
{
return type(iter.cons.get_tail());
}
};
template <typename I1, typename I2>
struct distance;
// detail
template <typename I1, typename I2>
struct lazy_next_distance
{
typedef
typename mpl::plus<
mpl::int_<1>,
typename distance<
typename next<I1>::type,
I2
>::type
>::type type;
};
template <typename I1, typename I2>
struct distance
{
typedef typename mpl::eval_if<
boost::is_same<I1, I2>,
mpl::int_<0>,
lazy_next_distance<I1, I2>
>::type type;
BOOST_FUSION_GPU_ENABLED
static type
call(I1 const&, I2 const&)
{
return type();
}
};
template <typename I1, typename I2>
struct equal_to
: is_same<typename I1::identity, typename I2::identity>
{};
private:
// silence MSVC warning C4512: assignment operator could not be generated
boost_tuple_iterator& operator= (boost_tuple_iterator const&);
};
template <typename Null>
struct boost_tuple_null_iterator
: iterator_facade<boost_tuple_iterator<Null>, forward_traversal_tag>
{
typedef Null cons_type;
typedef boost_tuple_iterator_identity<
typename add_const<Null>::type> identity;
template <typename I1, typename I2>
struct equal_to
: mpl::or_<
is_same<I1, I2>
, mpl::and_<
detail::boost_tuple_is_empty<typename I1::cons_type>
, detail::boost_tuple_is_empty<typename I2::cons_type>
>
>
{};
};
template <>
struct boost_tuple_iterator<tuples::null_type>
: boost_tuple_null_iterator<tuples::null_type>
{
template <typename Cons>
BOOST_FUSION_GPU_ENABLED
explicit boost_tuple_iterator(Cons const&) {}
};
template <>
struct boost_tuple_iterator<tuples::null_type const>
: boost_tuple_null_iterator<tuples::null_type const>
{
template <typename Cons>
BOOST_FUSION_GPU_ENABLED
explicit boost_tuple_iterator(Cons const&) {}
};
template <>
struct boost_tuple_iterator<tuples::tuple<> >
: boost_tuple_null_iterator<tuples::tuple<> >
{
template <typename Cons>
BOOST_FUSION_GPU_ENABLED
explicit boost_tuple_iterator(Cons const&) {}
};
template <>
struct boost_tuple_iterator<tuples::tuple<> const>
: boost_tuple_null_iterator<tuples::tuple<> const>
{
template <typename Cons>
BOOST_FUSION_GPU_ENABLED
explicit boost_tuple_iterator(Cons const&) {}
};
}}
#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
namespace std
{
template <typename Cons>
struct iterator_traits< ::boost::fusion::boost_tuple_iterator<Cons> >
{ };
}
#endif
#endif

View File

@ -1,52 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_AT_IMPL_09262006_1920)
#define BOOST_FUSION_AT_IMPL_09262006_1920
#include <boost/fusion/support/config.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/mpl/if.hpp>
namespace boost { namespace fusion
{
struct boost_tuple_tag;
namespace extension
{
template<typename T>
struct at_impl;
template <>
struct at_impl<boost_tuple_tag>
{
template <typename Sequence, typename N>
struct apply
{
typedef typename
tuples::element<N::value, Sequence>::type
element;
typedef typename
mpl::if_<
is_const<Sequence>
, typename tuples::access_traits<element>::const_type
, typename tuples::access_traits<element>::non_const_type
>::type
type;
BOOST_FUSION_GPU_ENABLED
static type
call(Sequence& seq)
{
return tuples::get<N::value>(seq);
}
};
};
}
}}
#endif

View File

@ -1,41 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_FUSION_BEGIN_IMPL_09272006_0719)
#define BOOST_FUSION_BEGIN_IMPL_09272006_0719
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp>
namespace boost { namespace fusion
{
struct boost_tuple_tag;
namespace extension
{
template<typename T>
struct begin_impl;
template <>
struct begin_impl<boost_tuple_tag>
{
template <typename Sequence>
struct apply
{
typedef boost_tuple_iterator<Sequence> type;
BOOST_FUSION_GPU_ENABLED
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

Some files were not shown because too many files have changed in this diff Show More