forked from boostorg/fusion
https://svn.boost.org/svn/boost/trunk ........ r42194 | anthonyw | 2007-12-19 23:46:00 -0800 (Wed, 19 Dec 2007) | 1 line added missing parentheses ........ r42195 | anthonyw | 2007-12-20 00:37:02 -0800 (Thu, 20 Dec 2007) | 1 line added hardware_concurrency support for apple, freebsd and sun platforms ........ r42196 | niels_dekker | 2007-12-20 01:09:44 -0800 (Thu, 20 Dec 2007) | 1 line Removed "mark-expected-failures" from value_init_test, for both Borland and GCC, as value_init.hpp changeset [41942] provides a workaround for them. ........ r42202 | fmhess | 2007-12-20 06:39:53 -0800 (Thu, 20 Dec 2007) | 6 lines Made putting the name of a typedef inside a "classname" element successfully produce a link to the typedef's reference documentation, or to the typedef's synopsis if that is all it has. ........ r42217 | vladimir_prus | 2007-12-20 13:18:47 -0800 (Thu, 20 Dec 2007) | 1 line Explain a couple of gcc limitations with precompiled headers ........ r42220 | matias | 2007-12-20 13:56:39 -0800 (Thu, 20 Dec 2007) | 1 line add explicit std::string initialization ........ r42221 | matias | 2007-12-20 13:59:18 -0800 (Thu, 20 Dec 2007) | 1 line add license to each html page ........ r42222 | matias | 2007-12-20 14:15:11 -0800 (Thu, 20 Dec 2007) | 1 line Time out: test_bimap_property_map @ gcc-3.4.6_linux_x86_64 ........ r42223 | djowel | 2007-12-20 15:24:28 -0800 (Thu, 20 Dec 2007) | 1 line Removing fusion variant adapter ........ r42224 | djowel | 2007-12-20 15:28:26 -0800 (Thu, 20 Dec 2007) | 1 line Removing fusion variant adapter ........ r42227 | nmusatti | 2007-12-20 23:03:44 -0800 (Thu, 20 Dec 2007) | 1 line Increased the latest supported version to 5.9.3, corresponding to the December 2007 update. ........ r42228 | anthonyw | 2007-12-21 02:54:59 -0800 (Fri, 21 Dec 2007) | 1 line Updated thread ID test ........ r42229 | anthonyw | 2007-12-21 03:05:37 -0800 (Fri, 21 Dec 2007) | 1 line Markup hardware_concurrency failure as expected on tru64 platforms, as support is not implemented ........ r42234 | dgregor | 2007-12-21 13:18:17 -0800 (Fri, 21 Dec 2007) | 1 line Reduce header dependencies, from Shunsuke Sogame. Fixes #1535 ........ [SVN r42236]
248 lines
6.8 KiB
Plaintext
248 lines
6.8 KiB
Plaintext
[/==============================================================================
|
|
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)
|
|
===============================================================================/]
|
|
[section Adapted]
|
|
|
|
Fusion provides a couple of adapters for other sequences such as
|
|
`std::pair`, __mpl__ sequences, and `boost::array`. These adapters are
|
|
written using Fusion's non-intrusive __extension__ mechanism. If you wish
|
|
to use these sequences with fusion, simply include the necessary files and
|
|
they will be regarded as first-class, fully conforming fusion sequences
|
|
[footnote Fusion sequences may also be adapted as fully conforming __mpl__
|
|
sequences (see __intrinsics__). That way, we can have 2-way adaptation to
|
|
and from __mpl__ and Fusion].
|
|
|
|
Fusion also provides various schemes to make it easy for the user to adapt
|
|
various data structures, non-intrusively, as full fledged Fusion sequences.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted.hpp>
|
|
#include <boost/fusion/include/adapted.hpp>
|
|
|
|
[section std::pair]
|
|
|
|
This module provides adapters for `std::pair`. Including the module header
|
|
makes `std::pair` a fully conforming __random_access_sequence__.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/std_pair.hpp>
|
|
#include <boost/fusion/include/std_pair.hpp>
|
|
|
|
[heading Model of]
|
|
|
|
* __random_access_sequence__
|
|
|
|
[heading Example]
|
|
|
|
std::pair<int, std::string> p(123, "Hola!!!");
|
|
std::cout << __at_c__<0>(p) << std::endl;
|
|
std::cout << __at_c__<1>(p) << std::endl;
|
|
std::cout << p << std::endl;
|
|
|
|
[heading See also]
|
|
|
|
__std_pair_doc__, __tr1_tuple_pair__
|
|
|
|
[endsect]
|
|
|
|
[section mpl sequence]
|
|
|
|
This module provides adapters for __mpl__ sequences. Including the module
|
|
header makes all __mpl__ sequences fully conforming fusion sequences.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/mpl.hpp>
|
|
#include <boost/fusion/include/mpl.hpp>
|
|
|
|
[heading Model of]
|
|
|
|
* __forward_sequence__ (If the __mpl__ sequence is a forward sequence.)
|
|
* __bidirectional_sequence__ (If the __mpl__ sequence is a bidirectional sequence.)
|
|
* __random_access_sequence__ (If the __mpl__ sequence is a random access sequence.)
|
|
|
|
[heading Example]
|
|
|
|
mpl::vector_c<int, 123, 456> vec_c;
|
|
fusion::vector2<int, long> v(vec_c);
|
|
std::cout << __at_c__<0>(v) << std::endl;
|
|
std::cout << __at_c__<1>(v) << std::endl;
|
|
|
|
v = mpl::vector_c<int, 456, 789>();
|
|
std::cout << __at_c__<0>(v) << std::endl;
|
|
std::cout << __at_c__<1>(v) << std::endl;
|
|
|
|
[heading See also]
|
|
|
|
__mpl__
|
|
|
|
[endsect]
|
|
|
|
[section boost::array]
|
|
|
|
This module provides adapters for `boost::array`. Including the module
|
|
header makes `boost::array` a fully conforming __random_access_sequence__.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/array.hpp>
|
|
#include <boost/fusion/include/array.hpp>
|
|
|
|
[heading Model of]
|
|
|
|
* __random_access_sequence__
|
|
|
|
[heading Example]
|
|
|
|
boost::array<int,3> arr = {{1,2,3}};
|
|
|
|
std::cout << *__begin__(arr) << std::endl;
|
|
std::cout << *__next__(__begin__(arr)) << std::endl;
|
|
std::cout << *__advance_c__<2>(__begin__(arr)) << std::endl;
|
|
std::cout << *__prior__(__end__(arr)) << std::endl;
|
|
std::cout << __at_c__<2>(arr) << std::endl;
|
|
|
|
[heading See also]
|
|
|
|
__boost_array_library__
|
|
|
|
[endsect]
|
|
|
|
[section boost::tuple]
|
|
This module provides adapters for `boost::tuple`. Including the module
|
|
header makes `boost::tuple` a fully conforming __forward_sequence__.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/boost_tuple.hpp>
|
|
#include <boost/fusion/include/boost_tuple.hpp>
|
|
|
|
[heading Model of]
|
|
|
|
* __forward_sequence__
|
|
|
|
[heading Example]
|
|
|
|
boost::tuple<int,std::string> example_tuple(101, "hello");
|
|
std::cout << *boost::fusion::begin(example_tuple) << '\n';
|
|
std::cout << *boost::fusion::next(boost::fusion::begin(example_tuple)) << '\n';
|
|
|
|
[heading See also]
|
|
|
|
__boost_tuple_library__
|
|
|
|
[endsect]
|
|
|
|
[section:adapt_struct BOOST_FUSION_ADAPT_STRUCT]
|
|
|
|
[heading Description]
|
|
BOOST_FUSION_ADAPT_STRUCT is a macro that can be used to generate all the
|
|
necessary boilerplate to make an arbitrary struct into a __random_access_sequence__.
|
|
|
|
[heading Synopsis]
|
|
BOOST_FUSION_ADAPT_STRUCT(
|
|
struct_name
|
|
(member_type0, member_name0)
|
|
(member_type1, member_name1)
|
|
...
|
|
)
|
|
|
|
[heading Semantics]
|
|
|
|
The above macro generates the necessary code to adapt `struct_name`
|
|
as a model of __random_access_sequence__. The sequence of `(member_typeN, member_nameN)`
|
|
pairs declare the type and names of each of the struct members that will be
|
|
part of the sequence.
|
|
|
|
The macro should be used at global scope, and `struct_name` should be the fully
|
|
namespace qualified name of the struct to be converted.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
|
#include <boost/fusion/include/adapt_struct.hpp>
|
|
|
|
[heading Example]
|
|
namespace demo
|
|
{
|
|
struct employee
|
|
{
|
|
std::string name;
|
|
int age;
|
|
};
|
|
}
|
|
|
|
// demo::employee is now a Fusion sequence
|
|
BOOST_FUSION_ADAPT_STRUCT(
|
|
demo::employee
|
|
(std::string, name)
|
|
(int, age))
|
|
|
|
[endsect]
|
|
|
|
[section:adapt_assoc BOOST_FUSION_ADAPT_ASSOC_STRUCT]
|
|
|
|
[heading Description]
|
|
BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the
|
|
necessary boilerplate to make an arbitrary struct into a model of __random_access_sequence__
|
|
and __associative_sequence__.
|
|
|
|
[heading Synopsis]
|
|
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
|
|
struct_name
|
|
(member_type0, member_name0, key_type0)
|
|
(member_type1, member_name1, key_type1)
|
|
...
|
|
)
|
|
|
|
[heading Semantics]
|
|
|
|
The above macro generates the necessary code to adapt `struct_name`
|
|
as a model of __random_access_sequence__ and __associative_sequence__.
|
|
The sequence of `(member_typeN, member_nameN, key_typeN)`
|
|
triples declare the type, name and key type of each of the struct members
|
|
that will be part of the sequence.
|
|
|
|
The macro should be used at global scope, and `struct_name` should be the fully
|
|
namespace qualified name of the struct to be converted.
|
|
|
|
[heading Header]
|
|
|
|
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp>
|
|
#include <boost/fusion/include/adapt_assoc_struct.hpp>
|
|
|
|
[heading Example]
|
|
namespace demo
|
|
{
|
|
struct employee
|
|
{
|
|
std::string name;
|
|
int age;
|
|
};
|
|
}
|
|
|
|
namespace keys
|
|
{
|
|
struct name;
|
|
struct age;
|
|
}
|
|
|
|
// demo::employee is now a Fusion sequence
|
|
// It is also an associative sequence with
|
|
// keys keys::name and keys::age present.
|
|
BOOST_FUSION_ADAPT_ASSOC_STRUCT(
|
|
demo::employee
|
|
(std::string, name, keys::name)
|
|
(int, age, keys::age))
|
|
|
|
|
|
[endsect]
|
|
|
|
[endsect]
|