[/============================================================================== 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 Container] Fusion provides a few predefined sequences out of the box. These /containers/ actually hold heterogeneously typed data; unlike __views__. These containers are more or less counterparts of those in __stl__. [heading Header] #include #include [section vector] [heading Description] `vector` is a __random_access_sequence__ of heterogeneous typed data structured as a simple `struct` where each element is held as a member variable. `vector` is the simplest of the Fusion sequence container (a vector with N elements is just a struct with N members), and in many cases the most efficient. [heading Header] #include #include #include #include // numbered forms #include #include #include #include #include #include #include #include #include #include [heading Synopsis] [*Numbered forms] struct vector0; template struct vector1; template struct vector2; template struct vector3; ... template struct vectorN; [important Numbered forms will be deprecated in C++11 and it will be provided via aliasing templates. It means that your partial specialization might be compile error. You can detect whether it is aliasing templates or not, using `BOOST_FUSION_HAS_VARIADIC_VECTOR`.] [*Variadic form] template < typename T0 = __unspecified__ , typename T1 = __unspecified__ , typename T2 = __unspecified__ ... , typename TN = __unspecified__ > struct vector; The numbered form accepts the exact number of elements. Example: vector3 For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the The variadic form accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. Example: vector You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`T0`...`TN`] [Element types] [__unspecified__]] ] [heading Model of] * __random_access_sequence__ [variablelist Notation [[`v`] [Instance of `vector`]] [[`V`] [A `vector` type]] [[`e0`...`en`] [Heterogeneous values]] [[`s`] [A __forward_sequence__]] ] [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]] [[`V()`] [Creates a vector with default constructed elements.]] [[`V(e0, e1,... en)`] [Creates a vector with elements `e0`...`en`.]] [[`V(s)`] [Copy constructs a vector from a __forward_sequence__, `s`.]] [[`v = s`] [Assigns to a vector, `v`, from a __forward_sequence__, `s`.]] ] [heading Example] vector v(12, 5.5f); std::cout << __at_c__<0>(v) << std::endl; std::cout << __at_c__<1>(v) << std::endl; [endsect] [section cons] [heading Description] `cons` is a simple __forward_sequence__. It is a lisp style recursive list structure where `car` is the /head/ and `cdr` is the /tail/: usually another cons structure or `nil`: the empty list. Fusion's __list__ is built on top of this more primitive data structure. It is more efficient than __vector__ when the target sequence is constructed piecemeal (a data at a time). The runtime cost of access to each element is peculiarly constant (see __recursive_inline__). [heading Header] #include #include [heading Synopsis] template struct cons; [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`Car`] [Head type] [ ]] [[`Cdr`] [Tail type] [`nil`]] ] [heading Model of] * __forward_sequence__ [variablelist Notation [[`nil`] [An empty `cons`]] [[`C`] [A `cons` type]] [[`l`, `l2`] [Instances of `cons`]] [[`car`] [An arbitrary data]] [[`cdr`] [Another `cons` list]] [[`s`] [A __forward_sequence__]] [[`N`] [An __mpl_integral_constant__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __forward_sequence__. [table [[Expression] [Semantics]] [[`nil()`] [Creates an empty list.]] [[`C()`] [Creates a cons with default constructed elements.]] [[`C(car)`] [Creates a cons with `car` head and default constructed tail.]] [[`C(car, cdr)`] [Creates a cons with `car` head and `cdr` tail.]] [[`C(s)`] [Copy constructs a cons from a __forward_sequence__, `s`.]] [[`l = s`] [Assigns to a cons, `l`, from a __forward_sequence__, `s`.]] [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] ] [note `__at__(l)` is provided for convenience and compatibility with the original __tuple__ library, despite `cons` being a __forward_sequence__ only (`at` is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is constant (see __recursive_inline__).] [heading Example] cons > l(12, cons(5.5f)); std::cout << __at_c__<0>(l) << std::endl; std::cout << __at_c__<1>(l) << std::endl; [endsect] [section list] [heading Description] `list` is a __forward_sequence__ of heterogeneous typed data built on top of __cons__. It is more efficient than __vector__ when the target sequence is constructed piecemeal (a data at a time). The runtime cost of access to each element is peculiarly constant (see __recursive_inline__). [heading Header] #include #include #include #include [heading Synopsis] template < typename T0 = __unspecified__ , typename T1 = __unspecified__ , typename T2 = __unspecified__ ... , typename TN = __unspecified__ > struct list; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic class interface accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. Example: list You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`T0`...`TN`] [Element types] [__unspecified__]] ] [heading Model of] * __forward_sequence__ [variablelist Notation [[`L`] [A `list` type]] [[`l`] [An instance of `list`]] [[`e0`...`en`] [Heterogeneous values]] [[`s`] [A __forward_sequence__]] [[`N`] [An __mpl_integral_constant__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __forward_sequence__. [table [[Expression] [Semantics]] [[`L()`] [Creates a list with default constructed elements.]] [[`L(e0, e1,... en)`] [Creates a list with elements `e0`...`en`.]] [[`L(s)`] [Copy constructs a list from a __forward_sequence__, `s`.]] [[`l = s`] [Assigns to a list, `l`, from a __forward_sequence__, `s`.]] [[`__at__(l)`] [The Nth element from the beginning of the sequence; see __at__.]] ] [note `__at__(l)` is provided for convenience and compatibility with the original __tuple__ library, despite `list` being a __forward_sequence__ only (__at__ is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is constant (see __recursive_inline__).] [heading Example] list l(12, 5.5f); std::cout << __at_c__<0>(l) << std::endl; std::cout << __at_c__<1>(l) << std::endl; [endsect] [section deque] [heading Description] `deque` is a simple __bidirectional_sequence__ that supports constant-time insertion and removal of elements at both ends. Like the __list__ and __cons__, `deque` is more efficient than __vector__ (especially at compile time) when the target sequence is constructed piecemeal (a data at a time, e.g. when constructing expression templates). Like the __list__ and __cons__, runtime cost of access to each element is peculiarly constant (see __recursive_inline__). Element insertion and removal are done by special `deque` helper classes __front_extended_deque__ and __back_extended_deque__. [heading Header] #include #include #include #include [heading Synopsis] template struct deque; For C++11 compilers, the variadic class interface has no upper bound. For C++03 compilers, the variadic class interface accepts `0` to `FUSION_MAX_DEQUE_SIZE` elements, where `FUSION_MAX_DEQUE_SIZE` is a user definable predefined maximum that defaults to `10`. Example: deque You may define the preprocessor constant `FUSION_MAX_DEQUE_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_DEQUE_SIZE 20 [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`Elements`] [Element types] [ ]] ] [heading Model of] * __bidirectional_sequence__ [variablelist Notation [[`D`] [A `deque` type]] [[`d`, `d2`] [Instances of `deque`]] [[`e0`...`en`] [Heterogeneous values]] [[`s`] [A __forward_sequence__]] [[`N`] [An __mpl_integral_constant__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __bidirectional_sequence__. [table [[Expression] [Semantics]] [[`D()`] [Creates a deque with default constructed elements.]] [[`D(e0, e1,... en)`] [Creates a deque with elements `e0`...`en`.]] [[`D(s)`] [Copy constructs a deque from a __forward_sequence__, `s`.]] [[`d = s`] [Assigns to a deque, `d`, from a __forward_sequence__, `s`.]] [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] [note `__at__(d)` is provided for convenience, despite `deque` being a __bidirectional_sequence__ only (`at` is supposed to be a __random_access_sequence__ requirement). The runtime complexity of __at__ is constant (see __recursive_inline__). `deque` element access utilizes operator overloading with argument dependent lookup (ADL) of the proper element getter function given a static constant index parameter. Interestingly, with modern C++ compilers, this lookup is very fast and rivals recursive template instantiations in compile time-speed, so much so that `deque` relies on ADL for all element access (indexing) as well as iteration.] [heading Example] deque d(12, 5.5f); std::cout << __at_c__<0>(d) << std::endl; std::cout << __at_c__<1>(d) << std::endl; [endsect] [section front_extended_deque] [heading Description] `front_extended_deque` allows a __deque__ to be front extended. It shares the same properties as the __deque__. [heading Header] See __deque__ [heading Synopsis] template struct front_extended_deque; [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`Deque`] [Deque type] [ ]] [[`T`] [Element type] [ ]] ] [note `Deque` can be a __deque__, a __front_extended_deque__ or a __back_extended_deque__] [heading Model of] * __bidirectional_sequence__ [variablelist Notation [[`D`] [A `front_extended_deque` type]] [[`e`] [Heterogeneous value]] [[`N`] [An __mpl_integral_constant__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __bidirectional_sequence__. [table [[Expression] [Semantics]] [[`D(d, e)`] [Extend `d` prepending `e` to its front.]] [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] [note See __deque__ for further details.] [heading Example] typedef deque initial_deque; initial_deque d(12, 5.5f); front_extended_deque d2(d, 999); std::cout << __at_c__<0>(d2) << std::endl; std::cout << __at_c__<1>(d2) << std::endl; std::cout << __at_c__<2>(d2) << std::endl; [endsect] [section back_extended_deque] [heading Description] `back_extended_deque` allows a __deque__ to be back extended. It shares the same properties as the __deque__. [heading Header] See __deque__ [heading Synopsis] template struct back_extended_deque; [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`Deque`] [Deque type] [ ]] [[`T`] [Element type] [ ]] ] [note `Deque` can be a __deque__, a __back_extended_deque__ or a __back_extended_deque__] [heading Model of] * __bidirectional_sequence__ [variablelist Notation [[`D`] [A `back_extended_deque` type]] [[`e`] [Heterogeneous value]] [[`N`] [An __mpl_integral_constant__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __bidirectional_sequence__. [table [[Expression] [Semantics]] [[`D(d, e)`] [Extend `d` prepending `e` to its back.]] [[`__at__(d)`] [The Nth element from the beginning of the sequence; see __at__.]] ] [note See __deque__ for further details.] [heading Example] typedef deque initial_deque; initial_deque d(12, 5.5f); back_extended_deque d2(d, 999); std::cout << __at_c__<0>(d2) << std::endl; std::cout << __at_c__<1>(d2) << std::endl; std::cout << __at_c__<2>(d2) << std::endl; [endsect] [section set] [heading Description] set is an __associative_sequence__ of heterogeneous typed data elements. Type identity is used to impose an equivalence relation on keys. The element's type is its key. A set may contain at most one element for each key. Membership testing and element key lookup has constant runtime complexity (see __overloaded_functions__). [heading Header] #include #include #include #include [heading Synopsis] template < typename T0 = __unspecified__ , typename T1 = __unspecified__ , typename T2 = __unspecified__ ... , typename TN = __unspecified__ > struct set; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic class interface accepts `0` to `FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that defaults to `10`. Example: set You may define the preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_SET_SIZE 20 [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`T0`...`TN`] [Element types] [__unspecified__]] ] [heading Model of] * __associative_sequence__ * __forward_sequence__ [variablelist Notation [[`S`] [A `set` type]] [[`s`] [An instance of `set`]] [[`e0`...`en`] [Heterogeneous values]] [[`fs`] [A __forward_sequence__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __random_access_sequence__ and __associative_sequence__. [table [[Expression] [Semantics]] [[`S()`] [Creates a set with default constructed elements.]] [[`S(e0, e1,... en)`] [Creates a set with elements `e0`...`en`.]] [[`S(fs)`] [Copy constructs a set from a __forward_sequence__ `fs`.]] [[`s = fs`] [Assigns to a set, `s`, from a __forward_sequence__ `fs`.]] ] [heading Example] typedef set S; S s(12, 5.5f); std::cout << __at_key__(s) << std::endl; std::cout << __at_key__(s) << std::endl; std::cout << __result_of_has_key__::value << std::endl; [endsect] [section map] [heading Description] map is an __associative_sequence__ of heterogeneous typed data elements. Each element is a key/data pair (see __fusion_pair__) where the key has no data (type only). Type identity is used to impose an equivalence relation on keys. A map may contain at most one element for each key. Membership testing and element key lookup has constant runtime complexity (see __overloaded_functions__). [heading Header] #include #include #include #include [heading Synopsis] template < typename T0 = __unspecified__ , typename T1 = __unspecified__ , typename T2 = __unspecified__ ... , typename TN = __unspecified__ > struct map; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic class interface accepts `0` to `FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that defaults to `10`. Example: map<__pair__, __pair__, __pair__ > You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_MAP_SIZE 20 [heading Template parameters] [table [[Parameter] [Description] [Default]] [[`T0`...`TN`] [Element types] [__unspecified__]] ] [heading Model of] * __associative_sequence__ * __random_access_sequence__ [variablelist Notation [[`M`] [A `map` type]] [[`m`] [An instance of `map`]] [[`e0`...`en`] [Heterogeneous key/value pairs (see __fusion_pair__)]] [[`s`] [A __forward_sequence__]] ] [heading Expression Semantics] Semantics of an expression is defined only where it differs from, or is not defined in __forward_sequence__ and __associative_sequence__. [table [[Expression] [Semantics]] [[`M()`] [Creates a map with default constructed elements.]] [[`M(e0, e1,... en)`] [Creates a map with element pairs `e0`...`en`.]] [[`M(s)`] [Copy constructs a map from a __forward_sequence__ `s`.]] [[`m = s`] [Assigns to a map, `m`, from a __forward_sequence__ `s`.]] ] [heading Example] typedef map< __pair__ , __pair__ > map_type; map_type m( __fusion_make_pair__('X') , __fusion_make_pair__("Men")); std::cout << __at_key__(m) << std::endl; std::cout << __at_key__(m) << std::endl; [endsect] [section Generation] These are the functions that you can use to generate various forms of __containers__ from elemental values. [heading Header] #include #include [section Functions] [section make_list] [heading Description] Create a __list__ from one or more values. [heading Synopsis] template typename __result_of_make_list__::type make_list(T0 const& x0, T1 const& x1... TN const& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_list`]] ] [heading Expression Semantics] make_list(x0, x1,... xN); [*Return type]: __result_of_make_list__`::type` [*Semantics]: Create a __list__ from `x0, x1,... xN`. [heading Header] #include #include [heading Example] make_list(123, "hello", 12.5) [heading See also] __note_ref_wrappers__ [endsect] [section make_cons] [heading Description] Create a __cons__ from `car` (/head/) and optional `cdr` (/tail/). [heading Synopsis] template typename __result_of_make_cons__::type make_cons(Car const& car); template typename __result_of_make_cons__::type make_cons(Car const& car, Cdr const& cdr); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`car`] [Instance of `Car`] [The list's head]] [[`cdr`] [Instance of `Cdr`] [The list's tail (optional)]] ] [heading Expression Semantics] make_cons(car, cdr); [*Return type]: __result_of_make_cons__`::type` or __result_of_make_cons__`::type` [*Semantics]: Create a __cons__ from `car` (/head/) and optional `cdr` (/tail/). [heading Header] #include #include [heading Example] make_cons('x', make_cons(123)) [heading See also] __note_ref_wrappers__ [endsect] [section make_vector] [heading Description] Create a __vector__ from one or more values. [heading Synopsis] template typename __result_of_make_vector__::type make_vector(T0 const& x0, T1 const& x1... TN const& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_vector`]] ] [heading Expression Semantics] make_vector(x0, x1,... xN); [*Return type]: __result_of_make_vector__`::type` [*Semantics]: Create a __vector__ from `x0, x1,... xN`. [heading Header] #include #include [heading Example] make_vector(123, "hello", 12.5) [heading See also] __note_ref_wrappers__ [endsect] [section make_deque] [heading Description] Create a __deque__ from one or more values. [heading Synopsis] template typename __result_of_make_deque__::type make_deque(Elements const&... elements); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_DEQUE_SIZE` elements, where `FUSION_MAX_DEQUE_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_DEQUE_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_DEQUE_SIZE 20 [heading Parameters] [table [[Parameter] [Description] [Description]] [[`elements`] [Instances of `Elements`] [The arguments to `make_deque`]] ] [heading Expression Semantics] make_deque(elements...); [*Return type]: __result_of_make_deque__`::type` [*Semantics]: Create a __deque__ from `elements...`. [heading Header] #include #include [heading Example] make_deque(123, "hello", 12.5) [heading See also] __note_ref_wrappers__ [endsect] [section make_set] [heading Description] Create a __set__ from one or more values. [heading Synopsis] template typename __result_of_make_set__::type make_set(T0 const& x0, T1 const& x1... TN const& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_SET_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_set`]] ] [heading Expression Semantics] make_set(x0, x1,... xN); [*Return type]: __result_of_make_set__`::type` [*Semantics]: Create a __set__ from `x0, x1,... xN`. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] make_set(123, "hello", 12.5) [heading See also] __note_ref_wrappers__ [endsect] [section make_map] [heading Description] Create a __map__ from one or more key/data pairs. [heading Synopsis] template < typename K0, typename K1,... typename KN , typename T0, typename T1,... typename TN> typename __result_of_make_map__::type make_map(T0 const& x0, T1 const& x1... TN const& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_MAP_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`K0, K1,... KN`] [The key types] [Keys associated with `x0, x1,... xN`]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `make_map`]] ] [heading Expression Semantics] make_map(x0, x1,... xN); [*Return type]: __result_of_make_map__`::type` [*Semantics]: Create a __map__ from `K0, K1,... KN` keys and `x0, x1,... xN` data. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] make_map('X', "Men") [heading See also] __note_ref_wrappers__, __fusion_pair__ [endsect] [section Tiers] Tiers are sequences, where all elements are non-const reference types. They are constructed with a call to a couple of /tie/ function templates. The succeeding sections document the various /tier/ flavors. * __list_tie__ * __vector_tie__ * __map_tie__ * __deque_tie__ Example: int i; char c; double d; ... __vector_tie__(i, c, d); The __vector_tie__ function creates a __vector__ of type `__vector__`. The same result could be achieved with the call __make_vector__(__boost_ref_call__(i), __boost_ref_call__(c), __boost_ref_call__(d)) [footnote see __boost_ref__ for details about `ref`]. A /tie/ can be used to 'unpack' another tuple into variables. E.g.: int i; char c; double d; __vector_tie__(i, c, d) = __make_vector__(1,'a', 5.5); std::cout << i << " " << c << " " << d; This code prints 1 a 5.5 to the standard output stream. A sequence unpacking operation like this is found for example in ML and Python. It is convenient when calling functions which return sequences. [heading Ignore] There is also an object called /ignore/ which allows you to ignore an element assigned by a sequence. The idea is that a function may return a sequence, only part of which you are interested in. For example: char c; __vector_tie__(ignore, c) = __make_vector__(1, 'a'); [endsect] [section list_tie] [heading Description] Constructs a tie using a __list__ sequence. [heading Synopsis] template __list__ list_tie(T0& x0, T1& x1... TN& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `list_tie`]] ] [heading Expression Semantics] list_tie(x0, x1,... xN); [*Return type]: __list__ [*Semantics]: Create a __list__ of references from `x0, x1,... xN`. [heading Header] #include #include [heading Example] int i = 123; double d = 123.456; list_tie(i, d) [endsect] [section vector_tie] [heading Description] Constructs a tie using a __vector__ sequence. [heading Synopsis] template __vector__ vector_tie(T0& x0, T1& x1... TN& xN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `vector_tie`]] ] [heading Expression Semantics] vector_tie(x0, x1,... xN); [*Return type]: __vector__ [*Semantics]: Create a __vector__ of references from `x0, x1,... xN`. [heading Header] #include #include [heading Example] int i = 123; double d = 123.456; vector_tie(i, d) [endsect] [section map_tie] [heading Description] Constructs a tie using a __map__ sequence. [heading Synopsis] template __map__<__pair__, __pair__,... __pair__ > map_tie(D0& d0, D1& d1... DN& dN); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that defaults to `10`, and a corresponding number of key types. You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_MAP_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`K0, K1,... KN`] [Any type][The key types associated with each of the `x1,x2,...,xN` values]] [[`x0, x1,... xN`] [Instances of `T0, T1,... TN`] [The arguments to `map_tie`]] ] [heading Expression Semantics] map_tie(x0, x1,... xN); [*Return type]: __map__<__pair__, __pair__,... __pair__ > [*Semantics]: Create a __map__ of references from `x0, x1,... xN` with keys `K0, K1,... KN` [heading Header] #include #include [heading Example] struct int_key; struct double_key; ... int i = 123; double d = 123.456; map_tie(i, d) [endsect] [section deque_tie] [heading Description] Constructs a tie using a __deque__ sequence. [heading Synopsis] template __deque__ deque_tie(Elements&... elements); For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_DEQUE_SIZE` elements, where `FUSION_MAX_DEQUE_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_DEQUE_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_DEQUE_SIZE 20 [heading Parameters] [table [[Parameter] [Description] [Description]] [[`elements`] [Instances of `Elements`] [The arguments to `deque_tie`]] ] [heading Expression Semantics] deque_tie(elements...); [*Return type]: __deque__ [*Semantics]: Create a __deque__ of references from `elements...`. [heading Header] #include #include [heading Example] int i = 123; double d = 123.456; deque_tie(i, d) [endsect] [endsect] [section MetaFunctions] [section make_list] [heading Description] Returns the result type of __make_list__. [heading Synopsis] template struct make_list; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`T0, T1,... TN`] [Any type] [Template arguments to `make_list`]] ] [heading Expression Semantics] result_of::make_list::type [*Return type]: A __list__ with elements of types converted following the rules for __element_conversion__. [*Semantics]: Create a __list__ from `T0, T1,... TN`. [heading Header] #include #include [heading Example] result_of::make_list::type [endsect] [section make_cons] [heading Description] Returns the result type of __make_cons__. [heading Synopsis] template struct make_cons; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Car`] [Any type] [The list's head type]] [[`Cdr`] [A `cons`] [The list's tail type (optional)]] ] [heading Expression Semantics] result_of::make_cons::type [*Return type]: A __cons__ with head element, `Car`, of type converted following the rules for __element_conversion__, and tail, `Cdr`. [*Semantics]: Create a __cons__ from `Car` (/head/) and optional `Cdr` (/tail/). [heading Header] #include #include [heading Example] result_of::make_cons::type>::type [endsect] [section make_vector] [heading Description] Returns the result type of __make_vector__. [heading Synopsis] template struct make_vector; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`T0, T1,... TN`] [Any type] [Template arguments to `make_vector`]] ] [heading Expression Semantics] result_of::make_vector::type [*Return type]: A __vector__ with elements of types converted following the rules for __element_conversion__. [*Semantics]: Create a __vector__ from `T0, T1,... TN`. [heading Header] #include #include [heading Example] result_of::make_vector::type [endsect] [section make_deque] [heading Description] Returns the result type of __make_deque__. [heading Synopsis] template struct make_deque; For C++11 compilers, the variadic template interface has no upper bound. For C++03 The variadic function accepts `0` to `FUSION_MAX_DEQUE_SIZE` elements, where `FUSION_MAX_DEQUE_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_DEQUE_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_DEQUE_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Elements`] [Variadic template types] [Template arguments to `make_deque`]] ] [heading Expression Semantics] result_of::make_deque::type [*Return type]: A __deque__ with elements of types converted following the rules for __element_conversion__. [*Semantics]: Create a __deque__ from `Elements...`. [heading Header] #include #include [heading Example] result_of::make_deque::type [endsect] [section make_set] [heading Description] Returns the result type of __make_set__. [heading Synopsis] template struct make_set; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_SET_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`T0, T1,... TN`] [Any type] [The arguments to `make_set`]] ] [heading Expression Semantics] result_of::make_set::type [*Return type]: A __set__ with elements of types converted following the rules for __element_conversion__. [*Semantics]: Create a __set__ from `T0, T1,... TN`. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] result_of::make_set::type [endsect] [section make_map] [heading Description] Returns the result type of __make_map__. The implementation depends on the support of variadic templates. When variadic templates are not supported, make_map is a metafunction of the form: [heading Synopsis] template < typename K0, typename K1,... typename KN , typename T0, typename T1,... typename TN> struct make_map; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_MAP_SIZE 20 When variadic templates are supported, make_map is a metafunction class of the form: [heading Synopsis] template < typename K0, typename K1,... typename KN> struct make_map { struct apply< typename T0, typename T1,... typename TN> }; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`K0, K1,... KN`] [Any type] [Keys associated with `T0, T1,... TN`]] [[`T0, T1,... TN`] [Any type] [Data associated with keys `K0, K1,... KN`]] ] [heading Expression Semantics] #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) resulf_of::make_map::type; #else resulf_of::make_map::apply::type; #endif [*Return type]: __result_of_make_map__`::type` when variadic templates are not supported, or __result_of_make_map__`::apply::type` when variadic templates are supported. [*Semantics]: A __map__ with __fusion_pair__ elements where the `second_type` is converted following the rules for __element_conversion__. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) result_of::make_map::type #else result_of::make_map::apply::type #endif [heading See also] __fusion_pair__ [endsect] [section list_tie] [heading Description] Returns the result type of __list_tie__. [heading Synopsis] template struct list_tie; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`T0, T1,... TN`] [Any type] [The arguments to `list_tie`]] ] [heading Expression Semantics] result_of::list_tie::type; [*Return type]: __list__ [*Semantics]: Create a __list__ of references from `T0, T1,... TN`. [heading Header] #include #include [heading Example] result_of::list_tie::type [endsect] [section vector_tie] [heading Description] Returns the result type of __vector_tie__. [heading Synopsis] template struct vector_tie; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`T0, T1,... TN`] [Any type] [The arguments to `vector_tie`]] ] [heading Expression Semantics] result_of::vector_tie::type; [*Return type]: __vector__ [*Semantics]: Create a __vector__ of references from `T0, T1,... TN`. [heading Header] #include #include [heading Example] result_of::vector_tie::type [endsect] [section deque_tie] [heading Description] Returns the result type of __deque_tie__. [heading Synopsis] template struct deque_tie; For C++11 compilers, the variadic template interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_DEQUE_SIZE` elements, where `FUSION_MAX_DEQUE_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_DEQUE_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_DEQUE_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Elements`] [Variadic template types] [Template arguments to `deque_tie`]] ] [heading Expression Semantics] result_of::deque_tie::type; [*Return type]: __deque__ [*Semantics]: Create a __deque__ of references from `Elements...`. [heading Header] #include #include [heading Example] result_of::deque_tie::type [endsect] [section map_tie] [heading Description] Returns the result type of __map_tie__. [heading Synopsis] template struct map_tie; For C++11 compilers, the variadic function interface has no upper bound. For C++03 compilers, the variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that defaults to `10`. You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change the default. Example: #define FUSION_MAX_MAP_SIZE 20 [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`K0, K1,... KN`] [Any type] [The key types for `map_tie`]] [[`D0, D1,... DN`] [Any type] [The arguments types for `map_tie`]] ] [heading Expression Semantics] result_of::map_tie::type; [*Return type]: __map__<__pair__, __pair__,... __pair__ > [*Semantics]: Create a __map__ of references from `D0, D1,... DN` with keys `K0, K1,... KN` [heading Header] #include #include [heading Example] struct int_key; struct double_key; ... result_of::map_tie::type [endsect] [endsect] [endsect] [section Conversion] All fusion sequences can be converted to one of the __containers__ types using one of these conversion functions. [heading Header] #include [section Functions] [section as_list] [heading Description] Convert a fusion sequence to a __list__. [heading Synopsis] template typename result_of::as_list::type as_list(Sequence& seq); template typename result_of::as_list::type as_list(Sequence const& seq); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`seq`] [An instance of Sequence] [The sequence to convert.]] ] [heading Expression Semantics] as_list(seq); [*Return type]: __result_of_as_list__`::type` [*Semantics]: Convert a fusion sequence, `seq`, to a __list__. [heading Header] #include #include [heading Example] as_list(__make_vector__('x', 123, "hello")) [endsect] [section as_vector] [heading Description] Convert a fusion sequence to a __vector__. [heading Synopsis] template typename result_of::as_vector::type as_vector(Sequence& seq); template typename result_of::as_vector::type as_vector(Sequence const& seq); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`seq`] [An instance of Sequence] [The sequence to convert.]] ] [heading Expression Semantics] as_vector(seq); [*Return type]: __result_of_as_vector__`::type` [*Semantics]: Convert a fusion sequence, `seq`, to a __vector__. [heading Header] #include #include [heading Example] as_vector(__make_list__('x', 123, "hello")) [endsect] [section as_deque] [heading Description] Convert a fusion sequence to a __deque__. [heading Synopsis] template typename result_of::as_deque::type as_deque(Sequence& seq); template typename result_of::as_deque::type as_deque(Sequence const& seq); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`seq`] [An instance of Sequence] [The sequence to convert.]] ] [heading Expression Semantics] as_deque(seq); [*Return type]: __result_of_as_deque__`::type` [*Semantics]: Convert a fusion sequence, `seq`, to a __deque__. [heading Header] #include #include [heading Example] as_deque(__make_vector__('x', 123, "hello")) [endsect] [section as_set] [heading Description] Convert a fusion sequence to a __set__. [heading Synopsis] template typename result_of::as_set::type as_set(Sequence& seq); template typename result_of::as_set::type as_set(Sequence const& seq); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`seq`] [An instance of Sequence] [The sequence to convert.]] ] [heading Expression Semantics] as_set(seq); [*Return type]: __result_of_as_set__`::type` [*Semantics]: Convert a fusion sequence, `seq`, to a __set__. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] as_set(__make_vector__('x', 123, "hello")) [endsect] [section as_map] [heading Description] Convert a fusion sequence to a __map__. [heading Synopsis] template typename result_of::as_map::type as_map(Sequence& seq); template typename result_of::as_map::type as_map(Sequence const& seq); [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`seq`] [An instance of Sequence] [The sequence to convert.]] ] [heading Expression Semantics] as_map(seq); [*Return type]: __result_of_as_map__`::type` [*Semantics]: Convert a fusion sequence, `seq`, to a __map__. [*Precondition]: For non-associative sequence, the elements are assumed to be __fusion_pair__s. There may be no duplicate __fusion_pair__ key types. [heading Header] #include #include [heading Example] // from sequence of __fusion_pair__ as_map(__make_vector__( __fusion_make_pair__('X') , __fusion_make_pair__("Men"))) // from associative sequence namespace ns { struct x_member; struct y_member; } BOOST_FUSION_DEFINE_ASSOC_STRUCT( (ns), point, (int, x, ns::x_member) (int, y, ns::y_member) ) ... as_map(ns::point(123, 456)) [endsect] [endsect] [section Metafunctions] [section as_list] [heading Description] Returns the result type of __as_list__. [heading Synopsis] template struct as_list; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Sequence`] [A fusion __sequence__] [The sequence type to convert.]] ] [heading Expression Semantics] result_of::as_list::type; [*Return type]: A __list__ with same elements as the input sequence, `Sequence`. [*Semantics]: Convert a fusion sequence, `Sequence`, to a __list__. [heading Header] #include #include [heading Example] result_of::as_list<__vector__ >::type [endsect] [section as_vector] [heading Description] Returns the result type of __as_vector__. [heading Synopsis] template struct as_vector; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] ] [heading Expression Semantics] result_of::as_vector::type; [*Return type]: A __vector__ with same elements as the input sequence, `Sequence`. [*Semantics]: Convert a fusion sequence, `Sequence`, to a __vector__. [heading Header] #include #include [heading Example] result_of::as_vector<__list__ >::type [endsect] [section as_deque] [heading Description] Returns the result type of __as_deque__. [heading Synopsis] template struct as_deque; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Sequence`] [A fusion __sequence__] [The sequence type to convert.]] ] [heading Expression Semantics] result_of::as_deque::type; [*Return type]: A __deque__ with same elements as the input sequence, `Sequence`. [*Semantics]: Convert a fusion sequence, `Sequence`, to a __deque__. [heading Header] #include #include [heading Example] result_of::as_deque<__vector__ >::type [endsect] [section as_set] [heading Description] Returns the result type of __as_set__. [heading Synopsis] template struct as_set; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] ] [heading Expression Semantics] result_of::as_set::type; [*Return type]: A __set__ with same elements as the input sequence, `Sequence`. [*Semantics]: Convert a fusion sequence, `Sequence`, to a __set__. [*Precondition]: There may be no duplicate key types. [heading Header] #include #include [heading Example] result_of::as_set<__vector__ >::type [endsect] [section as_map] [heading Description] Returns the result type of __as_map__. [heading Synopsis] template struct as_map; [heading Parameters] [table [[Parameter] [Requirement] [Description]] [[`Sequence`] [A fusion __sequence__] [The sequence to convert.]] ] [heading Expression Semantics] result_of::as_map::type; [*Return type]: A __map__ with same elements as the input sequence, `Sequence`. [*Semantics]: Convert a fusion sequence, `Sequence`, to a __map__. [*Precondition]: For non-associative sequence, the elements are assumed to be __fusion_pair__s. There may be no duplicate __fusion_pair__ key types. [heading Header] #include #include [heading Example] // from sequence of __fusion_pair__ result_of::as_map<__vector__< __fusion_pair__ , __fusion_pair__ > >::type // from associative sequence namespace ns { struct x_member; struct y_member; } BOOST_FUSION_DEFINE_ASSOC_STRUCT( (ns), point, (int, x, ns::x_member) (int, y, ns::y_member) ) ... result_of::as_map::type // __map__<__fusion_pair__, __fusion_pair__ > [endsect] [endsect] [endsect] [endsect]