From 0baf64588ccb22a29b023cefe29b1f16978ff93f Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 6 Nov 2007 10:09:38 +0000 Subject: [PATCH] doc updates to reflect structure changes [SVN r40827] --- doc/adapted.qbk | 155 ++++ doc/algorithms.qbk | 71 +- doc/container.qbk | 437 +++++++++++ doc/extension.qbk | 11 +- doc/functional.qbk | 33 +- doc/fusion.qbk | 231 +++--- doc/{iterators.qbk => iterator.qbk} | 82 +- doc/organization.qbk | 79 +- doc/{sequences.qbk => sequence.qbk} | 1109 +-------------------------- doc/{tuples.qbk => tuple.qbk} | 12 +- doc/view.qbk | 461 +++++++++++ 11 files changed, 1351 insertions(+), 1330 deletions(-) create mode 100644 doc/adapted.qbk create mode 100644 doc/container.qbk rename doc/{iterators.qbk => iterator.qbk} (94%) rename doc/{sequences.qbk => sequence.qbk} (69%) rename doc/{tuples.qbk => tuple.qbk} (98%) create mode 100644 doc/view.qbk diff --git a/doc/adapted.qbk b/doc/adapted.qbk new file mode 100644 index 00000000..b4518a38 --- /dev/null +++ b/doc/adapted.qbk @@ -0,0 +1,155 @@ +[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]. + +[heading Header] + + #include + +[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 + +[heading Model of] + +* __random_access_sequence__ + +[heading Example] + + std::pair 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 + +[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 vec_c; + fusion::vector2 v(vec_c); + std::cout << __at_c__<0>(v) << std::endl; + std::cout << __at_c__<1>(v) << std::endl; + + v = mpl::vector_c(); + 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 + +[heading Model of] + +* __random_access_sequence__ + +[heading Example] + + boost::array 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 + +[heading Model of] + +* __forward_sequence__ + +[heading Example] + + boost::tuple 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 boost::variant] +This module provides adapters for `boost::variant`. Including the module +header makes `boost::variant` a fully conforming __forward_sequence__. +The variant acts as a sequence of the types that can be contained in the variant. +Accessing types not currently stored int the variant will lead to the variant +being populated with a default constructed value of that type. + +[heading Header] + + #include + +[heading Model of] + +* __forward_sequence__ + +[heading Example] + + boost::variant example_variant = 101; + std::cout << example_variant << '\n'; + *boost::fusion::find(example_variant) = "hello"; + std::cout << example_variant << '\n'; + +[heading See also] + +__boost_variant_library__ + +[endsect] + +[endsect] diff --git a/doc/algorithms.qbk b/doc/algorithms.qbk index 44c46073..075fbe7b 100644 --- a/doc/algorithms.qbk +++ b/doc/algorithms.qbk @@ -35,6 +35,7 @@ may use one of the __conversion__ functions to convert back to the original sequence type. [heading Header] + #include [section Iteration] @@ -43,6 +44,7 @@ The iteration algorithms provide the fundamental algorithms for traversing a sequence repeatedly applying an operation to its elements. [heading Header] + #include [section Functions] @@ -79,6 +81,7 @@ For a sequence `Seq`, initial state, and binary function object or function poin Linear, exactly `__result_of_size__::value` applications of `f`. [heading Header] + #include [heading Example] @@ -130,6 +133,7 @@ For a sequence `Seq`, initial state, and binary function object or function poin Linear, exactly `__result_of_size__::value` applications of `f`. [heading Header] + #include [heading Example] @@ -179,6 +183,7 @@ Applies a unary function object to each element of a sequence. Linear, exactly `__result_of_size__::value` applications of `f`. [heading Header] + #include [heading Example] @@ -235,6 +240,7 @@ type `State` and binary function object or function pointer of type `F`. Linear, exactly `__result_of_size__::value` applications of `F`. [heading Header] + #include [endsect] @@ -273,6 +279,7 @@ type `State` and binary function object or function pointer of type `F`. Linear, exactly `__result_of_size__::value` applications of `F`. [heading Header] + #include [endsect] @@ -311,6 +318,7 @@ The return type is always `void`. Constant. [heading Header] + #include [endsect] @@ -323,6 +331,7 @@ Constant. The query algorithms provide support for searching and analyzing sequences. [heading Header] + #include [section Functions] @@ -357,6 +366,7 @@ For a sequence `seq` and unary function object `f`, `any` returns true if `f` re Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -404,6 +414,7 @@ For a sequence `seq` and unary function object `f`, `all` returns true if `f` re Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -451,6 +462,7 @@ For a sequence `seq` and unary function object `f`, `none` returns true if `f` r Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -504,6 +516,7 @@ Equivalent to `__find_if__ >(seq)` Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -549,8 +562,8 @@ or `__end__(seq)` if there is no such element. [heading Complexity] Linear. At most `__result_of_size__::value` comparisons. -[heading Header] - #include + +/algorithm/query/find_if.hpp> [heading Example] const __vector__ vec(1.0,2); @@ -589,6 +602,7 @@ Returns the number of elements of a given type within a sequence. Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -628,6 +642,7 @@ Returns the number of elements within a sequence with a type for which a given u Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [heading Example] @@ -672,6 +687,7 @@ A metafunction returning the result type of __any__. Constant. [heading Header] + #include [endsect] @@ -708,6 +724,7 @@ A metafunction returning the result type of __all__. Constant. [heading Header] + #include [endsect] @@ -744,6 +761,7 @@ A metafunction returning the result type of __none__. Constant. [heading Header] + #include [endsect] @@ -780,6 +798,7 @@ Returns the result type of `find`, given the sequence and search types. Linear, at most `__result_of_size__::value` comparisons. [heading Header] + #include [endsect] @@ -816,6 +835,7 @@ Returns the result type of `find_if` given the sequence and predicate types. Linear. At most `__result_of_size__::value` comparisons. [heading Header] + #include [endsect] @@ -852,6 +872,7 @@ A metafunction that returns the result type of `count` given the sequence and se Constant. [heading Header] + #include [endsect] @@ -888,6 +909,7 @@ A metafunction that returns the result type of `count_if` given the sequence and Constant. [heading Header] + #include [endsect] @@ -904,6 +926,7 @@ it is important that the lifetime of the input arguments is greater than the period during which you wish to use the results.] [heading Header] + #include [section Functions] @@ -938,6 +961,7 @@ Equivalent to `__filter_if__ >(seq)`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -977,6 +1001,7 @@ to `boost::mpl::true_`. The order of the retained elements is the same as in the Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1036,6 +1061,7 @@ with elements created by applying `f(e)` to each element of `e` of `seq`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1084,6 +1110,7 @@ Replaces each value within a sequence of a given type and value with a new value Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1124,6 +1151,7 @@ with `new_value` assigned to each element for which `f` evaluates to `true`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1170,6 +1198,7 @@ those of type `T`. Equivalent to `__remove_if__ >(seq)`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1210,6 +1239,7 @@ Equivalent to `__filter__ >(seq)`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1245,6 +1275,7 @@ Returns a new sequence with the elements of the original in reverse order. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1279,6 +1310,7 @@ __clear__ returns an empty sequence. Constant. [heading Header] + #include [heading Example] @@ -1333,6 +1365,7 @@ in the range [`first`,`last`). Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1372,6 +1405,7 @@ elements of the original except those with a given key. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1412,6 +1446,7 @@ type and value of `t` inserted at iterator `pos`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1453,6 +1488,7 @@ Returns a new sequence with another sequence inserted at a specified iterator. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1489,6 +1525,7 @@ Takes 2 sequences and returns a sequence containing the elements of the first fo Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1529,6 +1566,7 @@ Zips sequences together to form a single sequence, whos members are tuples of th Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1565,6 +1603,7 @@ Returns a new sequence, with the last element of the original removed. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1600,6 +1639,7 @@ Returns a new sequence, with the first element of the original removed. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1637,6 +1677,7 @@ Returns a new sequence with an element added at the end. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1674,6 +1715,7 @@ Returns a new sequence with an element added at the beginning. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1717,6 +1759,7 @@ Returns the result type of __filter__ given the sequence type and type to retain Constant. [heading Header] + #include [endsect] @@ -1753,6 +1796,7 @@ Returns the result type of __filter_if__ given the sequence and unary __mpl_lamb Constant. [heading Header] + #include [endsect] @@ -1808,6 +1852,7 @@ with elements created by applying `f(e)` to each element of `e` of `seq`. Constant. Returns a view which is lazily evaluated. [heading Header] + #include [heading Example] @@ -1857,6 +1902,7 @@ Returns the result type of __replace__, given the types of the input sequence an Constant. [heading Header] + #include [endsect] @@ -1894,6 +1940,7 @@ Returns the result type of __replace_if__, given the types of the sequence, __po Constant. [heading Header] + #include [endsect] @@ -1930,6 +1977,7 @@ Returns the result type of __remove__, given the sequence and removal types. Constant. [heading Header] + #include [endsect] @@ -1966,6 +2014,7 @@ Returns the result type of __remove_if__, given the input sequence and unary __m Constant. [heading Header] + #include [endsect] @@ -2000,6 +2049,7 @@ Returns the result type of __reverse__, given the input sequence type. Constant. [heading Header] + #include [endsect] @@ -2034,6 +2084,7 @@ Returns the result type of __clear__, given the input sequence type. Constant. [heading Header] + #include [endsect] @@ -2077,6 +2128,7 @@ Returns the result type of __erase__, given the input sequence and range delimit Constant. [heading Header] + #include [endsect] @@ -2113,6 +2165,7 @@ Returns the result type of __erase_key__, given the sequence and key types. Constant. [heading Header] + #include [endsect] @@ -2151,6 +2204,7 @@ Returns the result type of __insert__, given the sequence, position iterator and Constant. [heading Header] + #include [endsect] @@ -2189,6 +2243,7 @@ Returns the result type of __insert_range__, given the input sequence, position Constant. [heading Header] + #include [endsect] @@ -2219,6 +2274,7 @@ Returns the result of joining 2 sequences, given the sequence types. Constant. [heading Header] + #include [endsect] @@ -2251,6 +2307,7 @@ Zips sequences together to form a single sequence, whos members are tuples of th Constant. [heading Header] + #include [endsect] @@ -2285,6 +2342,7 @@ Returns the result type of __pop_back__, given the input sequence type. Constant. [heading Header] + #include [endsect] @@ -2318,8 +2376,7 @@ Returns the result type of __pop_front__, given the input sequence type. [heading Complexity] Constant. -[heading Header] - #include +/algorithm/transformation/pop_front.hpp> [endsect] @@ -2354,8 +2411,7 @@ Returns the result type of __push_back__, given the types of the input sequence [heading Complexity] Constant. -[heading Header] - #include +/algorithm/transformation/push_back.hpp> [endsect] @@ -2390,8 +2446,7 @@ Returns the result type of __push_front__, given the types of the input sequence [heading Complexity] Constant. -[heading Header] - #include +/algorithm/transformation/push_front.hpp> [endsect] diff --git a/doc/container.qbk b/doc/container.qbk new file mode 100644 index 00000000..ea90d939 --- /dev/null +++ b/doc/container.qbk @@ -0,0 +1,437 @@ +[section Container] + +Fusion provides a few predefined sequences out of the box. These +/containers/ actually hold heterogenously typed data; unlike +__views__. These containers are more or less counterparts of those in __stl__. + +[heading Header] + + #include + +[section vector] + +[heading Description] + +`vector` is a __random_access_sequence__ of heterogenous 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, and in many cases the most efficient. + +[heading Header] + + #include + #include + + // numbered forms + #include + #include + #include + #include + #include + +[heading Synopsis] + +[*Numbered forms] + + template <> + struct vector0; + + template + struct vector1; + + template + struct vector2; + + template + struct vector3; + + ... + + template + struct vectorN; + +[*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 + +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 + +[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__.]] +] + +[blurb __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 heterogenous 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 + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct list; + +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-type]]] +] + +[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__.]] +] + +[blurb __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 set] + +[heading Description] + +set is an __associative_sequence__ of heteregenous 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 + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct set; + +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-type]]] +] + +[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 heteregenous 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 + +[heading Synopsis] + + template < + typename T0 = __unspecified__ + , typename T1 = __unspecified__ + , typename T2 = __unspecified__ + ... + , typename TN = __unspecified__ + > + struct map; + +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-type]]] +] + +[heading Model of] + +* __associative_sequence__ +* __forward_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 __random_access_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] + +[endsect] diff --git a/doc/extension.qbk b/doc/extension.qbk index 68c12186..0115e5d2 100644 --- a/doc/extension.qbk +++ b/doc/extension.qbk @@ -66,7 +66,7 @@ that can be used in conjuction 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 + #include [heading Designing a suitable iterator] @@ -411,8 +411,7 @@ The user must the implement the key expressions required by their sequence type. [[`sequence::template value_at::type`][The type of the `N`th element in a sequence of type `Seq`]] ] -[heading Header] - #include +/sequence/sequence_facade.hpp> [endsect] @@ -493,8 +492,7 @@ 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 +/adapted/struct/adapt_struct.hpp> [heading Example] namespace demo @@ -546,8 +544,7 @@ 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 +/adapted/struct/adapt_assoc_struct.hpp> [heading Example] namespace demo diff --git a/doc/functional.qbk b/doc/functional.qbk index afacde35..eece4421 100644 --- a/doc/functional.qbk +++ b/doc/functional.qbk @@ -3,8 +3,7 @@ Components to call functions and function objects and to make Fusion code callable through a function object interface. -[heading Header] - #include +/functional.hpp> [heading Fused and unfused forms] @@ -283,8 +282,7 @@ arguments. [*Semantics]: Invokes `f` with the elements in `s` as arguments and returns the result of the call expression. -[heading Header] - #include +/functional/invocation/invoke.hpp> [heading Example] __std_plus_doc__ add; @@ -347,8 +345,7 @@ implemented). [*Semantics]: Invokes `f` with the elements in `s` as arguments. -[heading Header] - #include +/functional/invocation/invoke_procedure.hpp> [heading Example] __vector__ v(1,2); @@ -405,8 +402,7 @@ arguments. [*Semantics]: Invokes `f` with the elements in `s` as arguments and returns the result of the call expression. -[heading Header] - #include +/functional/invocation/invoke_function_object.hpp> [heading Example] struct sub @@ -548,8 +544,7 @@ In case of the latter, a freestanding [^get_pointer] function must be defined (Boost provides this function for [^std::auto_ptr] and __boost_shared_ptr_call__). -[heading Header] - #include +/functional/adapter/fused.hpp> [heading Synopsis] template @@ -625,8 +620,7 @@ The target function must not be a pointer to a member object (dereferencing such a pointer without returning anything does not make sense, so this case is not implemented). -[heading Header] - #include +/functional/adapter/fused_procedure.hpp> [heading Synopsis] template @@ -699,8 +693,7 @@ reference. Const qualification is preserved and propagated appropriately target function object that is const or, if the target function object is held by value, the adapter is const). -[heading Header] - #include +/functional/adapter/fused_function_object.hpp> [heading Synopsis] template @@ -799,8 +792,7 @@ reference. Const qualification is preserved and propagated appropriately the target function object is const - or, in case the target function object is held by value, the adapter is const). -[heading Header] - #include +/functional/adapter/unfused_generic.hpp> [heading Synopsis] template @@ -907,8 +899,7 @@ reference. Const qualification is preserved and propagated appropriately the target function object is const - or, in case the target function object is held by value, the adapter is const). -[heading Header] - #include +/functional/adapter/unfused_lvalue_args.hpp> [heading Synopsis] template @@ -989,8 +980,7 @@ reference. Const qualification is preserved and propagated appropriately the target function object is const - or, in case the target function object is held by value, the adapter is const). -[heading Header] - #include +/functional/adapter/unfused_rvalue_args.hpp> [heading Synopsis] template @@ -1081,8 +1071,7 @@ Therefore the adapter is always treated as if it was const. ] non-reference elements, the element is copied only once - the call operator's signature is optimized automatically to avoid by-value parameters.] -[heading Header] - #include +/functional/adapter/unfused_typed.hpp> [heading Synopsis] template diff --git a/doc/fusion.qbk b/doc/fusion.qbk index 570e897a..fda1dbca 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -65,125 +65,125 @@ [def __pair__ [link fusion.support.pair `pair`]] [def __fusion_make_pair__ [link fusion.support.pair `make_pair`]] -[def __iterator__ [link fusion.iterators Iterator]] -[def __iterator_concepts__ [link fusion.iterators.concepts Iterator Concepts]] -[def __forward_iterator__ [link fusion.iterators.concepts.forward_iterator Forward Iterator]] -[def __bidirectional_iterator__ [link fusion.iterators.concepts.bidirectional_iterator Bidirectional Iterator]] -[def __random_access_iterator__ [link fusion.iterators.concepts.random_access_iterator Random Access Iterator]] +[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 __next__ [link fusion.iterators.functions.next `next`]] -[def __prior__ [link fusion.iterators.functions.prior `prior`]] -[def __advance__ [link fusion.iterators.functions.advance `advance`]] -[def __advance_c__ [link fusion.iterators.functions.advance_c `advance_c`]] -[def __distance__ [link fusion.iterators.functions.distance `distance`]] -[def __deref__ [link fusion.iterators.functions.deref `deref`]] +[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 __result_of_next__ [link fusion.iterators.metafunctions.next `result_of::next`]] -[def __result_of_prior__ [link fusion.iterators.metafunctions.prior `result_of::prior`]] -[def __result_of_equal_to__ [link fusion.iterators.metafunctions.equal_to `result_of::equal_to`]] -[def __result_of_advance__ [link fusion.iterators.metafunctions.advance `result_of::advance`]] -[def __result_of_advance_c__ [link fusion.iterators.metafunctions.advance_c `result_of::advance_c`]] -[def __result_of_distance__ [link fusion.iterators.metafunctions.distance `result_of::distance`]] -[def __result_of_deref__ [link fusion.iterators.metafunctions.deref `result_of::deref`]] -[def __result_of_value_of__ [link fusion.iterators.metafunctions.value_of `result_of::value_of`]] -[def __value_of__ [link fusion.iterators.metafunctions.value_of `value_of`]] +[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 __value_of__ [link fusion.iterator.metafunctions.value_of `value_of`]] -[def __sequence__ [link fusion.sequences Sequence]] -[def __sequence_concepts__ [link fusion.sequences.concepts Sequence Concepts]] -[def __traversal_concept__ [link fusion.sequences.concepts.traversal Sequence Traversal Concept]] -[def __associativity_concept__ [link fusion.sequences.concepts.associativity Sequence Associativity Concept]] -[def __forward_sequence__ [link fusion.sequences.concepts.forward_sequence Forward Sequence]] -[def __bidirectional_sequence__ [link fusion.sequences.concepts.bidirectional_sequence Bidirectional Sequence]] -[def __random_access_sequence__ [link fusion.sequences.concepts.random_access_sequence Random Access Sequence]] -[def __associative_sequence__ [link fusion.sequences.concepts.associative_sequence Associative Sequence]] +[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 __containers__ [link fusion.sequences.containers Containers]] -[def __vector__ [link fusion.sequences.containers.vector `vector`]] -[def __cons__ [link fusion.sequences.containers.cons `cons`]] -[def __list__ [link fusion.sequences.containers.list `list`]] -[def __set__ [link fusion.sequences.containers.set `set`]] -[def __map__ [link fusion.sequences.containers.map `map`]] +[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 __set__ [link fusion.container.set `set`]] +[def __map__ [link fusion.container.map `map`]] -[def __view__ [link fusion.sequences.views View]] -[def __views__ [link fusion.sequences.views Views]] -[def __single_view__ [link fusion.sequences.views.single_view `single_view`]] -[def __filter_view__ [link fusion.sequences.views.filter_view `filter_view`]] -[def __iterator_range__ [link fusion.sequences.views.iterator_range `iterator_range`]] -[def __joint_view__ [link fusion.sequences.views.joint_view `joint_view`]] -[def __transform_view__ [link fusion.sequences.views.transform_view `transform_view`]] -[def __reverse_view__ [link fusion.sequences.views.reverse_view `reverse_view`]] -[def __zip_view__ [link fusion.sequences.views.zip_view `zip_view`]] +[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 __std_pair__ [link fusion.sequences.adapted.std__pair `std::pair`]] -[def __boost_array__ [link fusion.sequences.adapted.boost__array `boost::array`]] -[def __mpl_sequence__ [link fusion.sequences.adapted.mpl_sequence mpl sequence]] +[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 __intrinsic__ [link fusion.sequences.intrinsics Intrinsic]] -[def __intrinsics__ [link fusion.sequences.intrinsics Intrinsics]] -[def __begin__ [link fusion.sequences.intrinsics.functions.begin `begin`]] -[def __result_of_begin__ [link fusion.sequences.intrinsics.metafunctions.begin `result_of::begin`]] -[def __end__ [link fusion.sequences.intrinsics.functions.end `end`]] -[def __result_of_end__ [link fusion.sequences.intrinsics.metafunctions.end `result_of::end`]] -[def __size__ [link fusion.sequences.intrinsics.functions.size `size`]] -[def __result_of_size__ [link fusion.sequences.intrinsics.metafunctions.size `result_of::size`]] -[def __empty__ [link fusion.sequences.intrinsics.functions.empty `empty`]] -[def __result_of_empty__ [link fusion.sequences.intrinsics.metafunctions.empty `result_of::empty`]] -[def __front__ [link fusion.sequences.intrinsics.functions.front `front`]] -[def __result_of_front__ [link fusion.sequences.intrinsics.metafunctions.front `result_of::front`]] -[def __back__ [link fusion.sequences.intrinsics.functions.back `back`]] -[def __result_of_back__ [link fusion.sequences.intrinsics.metafunctions.back `result_of::back`]] -[def __at__ [link fusion.sequences.intrinsics.functions.at `at`]] -[def __result_of_at__ [link fusion.sequences.intrinsics.metafunctions.at `result_of::at`]] -[def __at_c__ [link fusion.sequences.intrinsics.functions.at_c `at_c`]] -[def __result_of_at_c__ [link fusion.sequences.intrinsics.metafunctions.at_c `result_of::at_c`]] -[def __at_key__ [link fusion.sequences.intrinsics.functions.at_key `at_key`]] -[def __result_of_at_key__ [link fusion.sequences.intrinsics.metafunctions.at_key `result_of::at_key`]] -[def __has_key__ [link fusion.sequences.intrinsics.functions.has_key `has_key`]] -[def __result_of_has_key__ [link fusion.sequences.intrinsics.metafunctions.has_key `result_of::has_key`]] -[def __value_at_key__ [link fusion.sequences.intrinsics.metafunctions.value_at_key `value_at_key`]] -[def __result_of_value_at__ [link fusion.sequences.intrinsics.metafunctions.value_at `result_of::value_at`]] -[def __result_of_value_at_c__ [link fusion.sequences.intrinsics.metafunctions.value_at_c `result_of::value_at_c`]] -[def __result_of_value_at_key__ [link fusion.sequences.intrinsics.metafunctions.value_at_key `result_of::value_at_key`]] +[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 __value_at_key__ [link fusion.sequence.intrinsic.metafunctions.value_at_key `value_at_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 __conversion__ [link fusion.sequences.conversion.functions Conversion]] -[def __result_of_conversion__ [link fusion.sequences.conversion.metafunctions Conversion Metafunctions]] -[def __as_vector__ [link fusion.sequences.conversion.functions.as_vector `as_vector`]] -[def __result_of_as_vector__ [link fusion.sequences.conversion.metafunctions.as_vector `result_of::as_vector`]] -[def __as_list__ [link fusion.sequences.conversion.functions.as_list `as_list`]] -[def __result_of_as_list__ [link fusion.sequences.conversion.metafunctions.as_list `result_of::as_list`]] -[def __as_set__ [link fusion.sequences.conversion.functions.as_set `as_set`]] -[def __result_of_as_set__ [link fusion.sequences.conversion.metafunctions.as_set `result_of::as_set`]] -[def __as_map__ [link fusion.sequences.conversion.functions.as_map `as_map`]] -[def __result_of_as_map__ [link fusion.sequences.conversion.metafunctions.as_map `result_of::as_map`]] +[def __conversion__ [link fusion.sequence.conversion.functions Conversion]] +[def __result_of_conversion__ [link fusion.sequence.conversion.metafunctions Conversion Metafunctions]] +[def __as_vector__ [link fusion.sequence.conversion.functions.as_vector `as_vector`]] +[def __result_of_as_vector__ [link fusion.sequence.conversion.metafunctions.as_vector `result_of::as_vector`]] +[def __as_list__ [link fusion.sequence.conversion.functions.as_list `as_list`]] +[def __result_of_as_list__ [link fusion.sequence.conversion.metafunctions.as_list `result_of::as_list`]] +[def __as_set__ [link fusion.sequence.conversion.functions.as_set `as_set`]] +[def __result_of_as_set__ [link fusion.sequence.conversion.metafunctions.as_set `result_of::as_set`]] +[def __as_map__ [link fusion.sequence.conversion.functions.as_map `as_map`]] +[def __result_of_as_map__ [link fusion.sequence.conversion.metafunctions.as_map `result_of::as_map`]] -[def __generation__ [link fusion.sequences.generation.functions Generation]] -[def __result_of_generation__ [link fusion.sequences.generation.metafunctions Generation Metafunctions]] -[def __make_vector__ [link fusion.sequences.generation.functions.make_vector `make_vector`]] -[def __result_of_make_vector__ [link fusion.sequences.generation.metafunctions.make_vector `result_of::make_vector`]] -[def __vector_tie__ [link fusion.sequences.generation.functions.vector_tie `vector_tie`]] -[def __map_tie__ [link fusion.sequences.generation.functions.vector_tie `map_tie`]] -[def __result_of_vector_tie__ [link fusion.sequences.generation.metafunctions.vector_tie `result_of::vector_tie`]] -[def __make_vector__ [link fusion.sequences.generation.functions.make_vector `make_vector`]] -[def __result_of_make_vector__ [link fusion.sequences.generation.metafunctions.make_vector `result_of::make_vector`]] -[def __make_cons__ [link fusion.sequences.generation.functions.make_cons `make_cons`]] -[def __result_of_make_cons__ [link fusion.sequences.generation.metafunctions.make_cons `result_of::make_cons`]] -[def __make_list__ [link fusion.sequences.generation.functions.make_list `make_list`]] -[def __result_of_make_list__ [link fusion.sequences.generation.metafunctions.make_list `result_of::make_list`]] -[def __make_set__ [link fusion.sequences.generation.functions.make_set `make_set`]] -[def __result_of_make_set__ [link fusion.sequences.generation.metafunctions.make_set `result_of::make_set`]] -[def __make_map__ [link fusion.sequences.generation.functions.make_map `make_map`]] -[def __result_of_make_map__ [link fusion.sequences.generation.metafunctions.make_map `result_of::make_map`]] -[def __list_tie__ [link fusion.sequences.generation.functions.list_tie `list_tie`]] -[def __result_of_list_tie__ [link fusion.sequences.generation.metafunctions.list_tie `result_of::list_tie`]] +[def __generation__ [link fusion.sequence.generation.functions Generation]] +[def __result_of_generation__ [link fusion.sequence.generation.metafunctions Generation Metafunctions]] +[def __make_vector__ [link fusion.sequence.generation.functions.make_vector `make_vector`]] +[def __result_of_make_vector__ [link fusion.sequence.generation.metafunctions.make_vector `result_of::make_vector`]] +[def __vector_tie__ [link fusion.sequence.generation.functions.vector_tie `vector_tie`]] +[def __map_tie__ [link fusion.sequence.generation.functions.vector_tie `map_tie`]] +[def __result_of_vector_tie__ [link fusion.sequence.generation.metafunctions.vector_tie `result_of::vector_tie`]] +[def __make_vector__ [link fusion.sequence.generation.functions.make_vector `make_vector`]] +[def __result_of_make_vector__ [link fusion.sequence.generation.metafunctions.make_vector `result_of::make_vector`]] +[def __make_cons__ [link fusion.sequence.generation.functions.make_cons `make_cons`]] +[def __result_of_make_cons__ [link fusion.sequence.generation.metafunctions.make_cons `result_of::make_cons`]] +[def __make_list__ [link fusion.sequence.generation.functions.make_list `make_list`]] +[def __result_of_make_list__ [link fusion.sequence.generation.metafunctions.make_list `result_of::make_list`]] +[def __make_set__ [link fusion.sequence.generation.functions.make_set `make_set`]] +[def __result_of_make_set__ [link fusion.sequence.generation.metafunctions.make_set `result_of::make_set`]] +[def __make_map__ [link fusion.sequence.generation.functions.make_map `make_map`]] +[def __result_of_make_map__ [link fusion.sequence.generation.metafunctions.make_map `result_of::make_map`]] +[def __list_tie__ [link fusion.sequence.generation.functions.list_tie `list_tie`]] +[def __result_of_list_tie__ [link fusion.sequence.generation.metafunctions.list_tie `result_of::list_tie`]] -[def __out__ [link fusion.sequences.operators.i_o.out out]] -[def __in__ [link fusion.sequences.operators.i_o.in in]] -[def __eq__ [link fusion.sequences.operators.comparison.equal equal]] -[def __neq__ [link fusion.sequences.operators.comparison.not_equal not equal]] -[def __lt__ [link fusion.sequences.operators.comparison.less_than less than]] -[def __lte__ [link fusion.sequences.operators.comparison.less_than_equal less than equal]] -[def __gt__ [link fusion.sequences.operators.comparison.greater_than greater than]] -[def __gte__ [link fusion.sequences.operators.comparison.greater_than_equal greater than equal]] +[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.algorithms Algorithm]] [def __algorithms__ [link fusion.algorithms Algorithms]] @@ -246,8 +246,8 @@ [def __push_front__ [link fusion.algorithms.transformation.functions.push_front `push_front`]] [def __result_of_push_front__ [link fusion.algorithms.transformation.metafunctions.push_front `result_of::push_front`]] -[def __tr1_tuple_pair__ [link fusion.tuples.pairs `TR1 and std::pair`]] -[def __tuple_get__ [link fusion.tuples.class_template_tuple.element_access `get`]] +[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]] @@ -298,10 +298,13 @@ [include quick_start.qbk] [include organization.qbk] [include support.qbk] -[include iterators.qbk] -[include sequences.qbk] +[include iterator.qbk] +[include sequence.qbk] +[include container.qbk] +[include view.qbk] +[include adapted.qbk] [include algorithms.qbk] -[include tuples.qbk] +[include tuple.qbk] [include extension.qbk] [include functional.qbk] [include notes.qbk] diff --git a/doc/iterators.qbk b/doc/iterator.qbk similarity index 94% rename from doc/iterators.qbk rename to doc/iterator.qbk index 1607242a..ebaccc92 100644 --- a/doc/iterators.qbk +++ b/doc/iterator.qbk @@ -1,16 +1,16 @@ -[section Iterators] -Like __mpl__ and __stl__, iterators are a fundamental concept in Fusion. +[section Iterator] + +Like __mpl__ and __stl__, iterators are a fundamental concept in Fusion. As with __mpl__ and __stl__ iterators describe positions, and provide access to data within an underlying __sequence__. -[heading Header] - #include +/iterator.hpp> [section Concepts] Fusion iterators are divided into different traversal categories. -__forward_iterator__ is the most basic concept. __bidirectional_iterator__ -is a refinement of __forward_iterator__. __random_access_iterator__ is a +__forward_iterator__ is the most basic concept. __bidirectional_iterator__ +is a refinement of __forward_iterator__. __random_access_iterator__ is a refinement of __bidirectional_iterator__. [section Forward Iterator] @@ -111,7 +111,7 @@ element at a time. __forward_iterator__ [heading Expression requirements] -In addition to the requirements defined in __forward_iterator__, +In addition to the requirements defined in __forward_iterator__, the following expressions must be valid: [table @@ -138,7 +138,7 @@ in __forward_iterator__ ] [heading Invariants] -In addition to the invariants of __forward_iterator__, +In addition to the invariants of __forward_iterator__, the following invariants always hold: * `__prior__(__next__(i)) == i && __prior__(__next__(i)) == __next__(__prior__(i))` @@ -172,7 +172,7 @@ sequence. __bidirectional_iterator__ [heading Expression requirements] -In addition to the requirements defined in __bidirectional_iterator__, +In addition to the requirements defined in __bidirectional_iterator__, the following expressions must be valid: [table @@ -204,7 +204,7 @@ the following expressions must be valid: [endsect] [section Functions] -Fusion provides functions for manipulating iterators, analogous to the similar functions +Fusion provides functions for manipulating iterators, analogous to the similar functions from the __mpl__ library. [section deref] @@ -230,12 +230,11 @@ Deferences an iterator. [*Semantics]: Dereferences the iterator `i`. -[heading Header] - #include +/iterator/deref.hpp> [heading Example] typedef __vector__ vec; - + int i(0); vec v(1,i); assert(__deref__(__begin__(v)) == 1); @@ -267,8 +266,7 @@ Moves an iterator 1 position forwards. [*Semantics]: Returns an iterator to the next element after `i`. -[heading Header] - #include +/iterator/next.hpp> [heading Example] typedef __vector__ vec; @@ -303,8 +301,7 @@ Moves an iterator 1 position backwards. [*Semantics]: Returns an iterator to the element prior to `i`. -[heading Header] - #include +/iterator/prior.hpp> [heading Example] typedef __vector__ vec; @@ -339,8 +336,7 @@ Returns the distance between 2 iterators. [*Semantics]: Returns the distance between iterators `i` and `j`. -[heading Header] - #include +/iterator/distance.hpp> [heading Example] typedef __vector__ vec; @@ -360,7 +356,7 @@ Moves an iterator by a specified distance. typename I, typename M > - typename __result_of_advance__::type advance(I const& i); + typename __result_of_advance__::type advance(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] @@ -375,8 +371,7 @@ Moves an iterator by a specified distance. [*Semantics]: Returns an iterator to the element `M` positions from `i`. If `i` is a __bidirectional_iterator__ then `M` may be negative. -[heading Header] - #include +/iterator/advance.hpp> [heading Example] typedef __vector__ vec; @@ -396,7 +391,7 @@ Moves an iterator by a specified distance. typename I, int N > - typename __result_of_advance_c__::type advance_c(I const& i); + typename __result_of_advance_c__::type advance_c(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] @@ -411,8 +406,7 @@ Moves an iterator by a specified distance. [*Semantics]: Returns an iterator to the element `N` positions from `i`. If `i` is a __bidirectional_iterator__ then `N` may be negative. -[heading Header] - #include +/iterator/advance.hpp> [heading Example] typedef __vector__ vec; @@ -424,7 +418,8 @@ Moves an iterator by a specified distance. [endsect] -[section Operators] +[section Operator] + Overloaded operators are provided to provide a more natural syntax for dereferencing iterators, and comparing them for equality. [section:operator_unary_star Operator *] @@ -450,12 +445,11 @@ Dereferences an iterator. [*Semantics]: Equivalent to `__deref__(i)`. -[heading Header] - #include +/iterator/deref.hpp> [heading Example] typedef __vector__ vec; - + int i(0); vec v(1,i); assert(*__begin__(v) == 1); @@ -488,8 +482,7 @@ Compares 2 iterators for equality. [*Semantics]: Equivalent to `__result_of_equal_to__::value` where `I` and `J` are the types of `i` and `j` respectively. -[heading Header] - #include +/iterator/equal_to.hpp> [endsect] @@ -516,8 +509,7 @@ Compares 2 iterators for inequality. [*Semantics]: Equivalent to `!__result_of_equal_to__::value` where `I` and `J` are the types of `i` and `j` respectively. -[heading Header] - #include +/iterator/equal_to.hpp> [endsect] @@ -552,8 +544,7 @@ Returns the type stored at the position of an iterator. [*Semantics]: Returns the type stored in a sequence at iterator position `I`. -[heading Header] - #include +/iterator/value_of.hpp> [heading Example] typedef __vector__ vec; @@ -593,8 +584,7 @@ Returns the type that will be returned by dereferencing an iterator. [*Semantics]: Returns the result of dereferencing an iterator of type `I`. -[heading Header] - #include +/iterator/deref.hpp> [heading Example] typedef __vector__ vec; @@ -636,8 +626,7 @@ Returns the type of the next iterator in a sequence. [*Semantics]: Returns an iterator to the next element in the sequence after `I`. -[heading Header] - #include +/iterator/next.hpp> [heading Example] typedef __vector__ vec; @@ -673,8 +662,7 @@ Returns the type of the previous iterator in a sequence. [*Semantics]: Returns an iterator to the previous element in the sequence before `I`. -[heading Header] - #include +/iterator/prior.hpp> [heading Example] typedef __vector__ vec; @@ -714,8 +702,7 @@ Returns a true-valued __mpl_integral_constant__ if `I` and `J` are equal. [*Semantics]: Returns `boost::mpl::true_` if `I` and `J` are iterators to the same position. Returns `boost::mpl::false_` otherwise. -[heading Header] - #include +/iterator/equal_to.hpp> [heading Example] typedef __vector__ vec; @@ -753,8 +740,7 @@ Returns the distance between two iterators. [*Semantics]: Returns the distance between iterators of types `I` and `J`. -[heading Header] - #include +/iterator/distance.hpp> [heading Example] typedef __vector__ vec; @@ -795,8 +781,7 @@ Moves an iterator a specified distance. [*Semantics]: Returns an iterator a distance `M` from `I`. If `I` is a __bidirectional_iterator__ then `M` may be negative. -[heading Header] - #include +/iterator/advance.hpp> [heading Example] typedef __vector__ vec; @@ -836,8 +821,7 @@ Moves an iterator by a specified distance. [*Semantics]: Returns an iterator a distance `N` from `I`. If `I` is a __bidirectional_iterator__ then `N` may be negative. Equivalent to `__result_of_advance__ >::type`. -[heading Header] - #include +/iterator/advance.hpp> [heading Example] typedef __vector__ vec; diff --git a/doc/organization.qbk b/doc/organization.qbk index cff048f8..71fd1a91 100644 --- a/doc/organization.qbk +++ b/doc/organization.qbk @@ -9,13 +9,20 @@ The library is organized in three 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. The -library is header-only. There is no need to build object files to link -against. +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] @@ -24,45 +31,49 @@ against. * iteration * query * transformation +* adapted + * array + * mpl + * boost::tuple + * std_pair + * struct + * variant +* view + * filter_view + * iterator_range + * joint_view + * reverse_view + * single_view + * transform_view + * zip_view +* container + * deque + * list + * map + * set + * vector +* mpl +* functional * sequence - * adapted - * array - * mpl - * std_pair * comparison - * container - * list - * map - * set - * vector * conversion - * generation * intrinsic * io * utility - * view - * filter_view - * iterator_range - * joint_view - * reverse_view - * single_view - * transform_view - * zip_view * iterator * support [heading Example] -If, for example, you want to use `list`, depending on the granularity that +If, for example, you want to use `list`, depending on the granularity that you desire, you may do so by including one of - #include - #include - #include - -The first includes all sequences. The second includes all of sequence -containers. The third 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.]. + #include + #include + +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] diff --git a/doc/sequences.qbk b/doc/sequence.qbk similarity index 69% rename from doc/sequences.qbk rename to doc/sequence.qbk index ae1ce0ea..65297189 100644 --- a/doc/sequences.qbk +++ b/doc/sequence.qbk @@ -1,4 +1,4 @@ -[section Sequences] +[section Sequence] Like __mpl__, the Sequence is a fundamental concept in Fusion. A Sequence may or may not actually store or contain data. __containers__ are sequences @@ -337,1065 +337,9 @@ you can use `__result_of_value_at_key__`.] [endsect] -[section Containers] +[section Intrinsic] -Fusion provides a few predefined sequences out of the box. These -/containers/ actually hold heterogenously typed data; unlike -__views__. These containers are more or less counterparts of those in __stl__. - -[heading Header] - - #include - -[section vector] - -[heading Description] - -`vector` is a __random_access_sequence__ of heterogenous 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, and in many cases the most efficient. - -[heading Header] - - #include - #include - - // numbered forms - #include - #include - #include - #include - #include - -[heading Synopsis] - -[*Numbered forms] - - template <> - struct vector0; - - template - struct vector1; - - template - struct vector2; - - template - struct vector3; - - ... - - template - struct vectorN; - -[*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 - -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 - -[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__.]] -] - -[blurb __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 heterogenous 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 - -[heading Synopsis] - - template < - typename T0 = __unspecified__ - , typename T1 = __unspecified__ - , typename T2 = __unspecified__ - ... - , typename TN = __unspecified__ - > - struct list; - -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-type]]] -] - -[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__.]] -] - -[blurb __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 set] - -[heading Description] - -set is an __associative_sequence__ of heteregenous 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 - -[heading Synopsis] - - template < - typename T0 = __unspecified__ - , typename T1 = __unspecified__ - , typename T2 = __unspecified__ - ... - , typename TN = __unspecified__ - > - struct set; - -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-type]]] -] - -[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 heteregenous 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 - -[heading Synopsis] - - template < - typename T0 = __unspecified__ - , typename T1 = __unspecified__ - , typename T2 = __unspecified__ - ... - , typename TN = __unspecified__ - > - struct map; - -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-type]]] -] - -[heading Model of] - -* __associative_sequence__ -* __forward_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 __random_access_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] - -[endsect] - -[section 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. 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 - -[section single_view] - -`single_view` is a view into a value as a single element sequence. - -[heading Header] - - #include - -[heading Synopsis] - - template - struct single_view; - -[heading Template parameters] - -[table - [[Parameter] [Description] [Default]] - [[`T`] [Any type] []] -] - -[heading Model of] - -* __forward_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 __forward_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 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 - -[heading Synopsis] - - template - 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__ - -[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 __forward_sequence__. - -[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__ vector_type; - - vector_type v("a-string", '@', 987654, true, 6.6); - filter_view > > 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 - -[heading Synopsis] - - template - 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. - -[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 __forward_sequence__. - -[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__ vector_type; - vector_type vec(1, 'x', 3.3, s); - - typedef __result_of_begin__::type A; - typedef __result_of_end__::type B; - typedef __result_of_next__::type C; - typedef __result_of_prior__::type D; - - C c(vec); - D d(vec); - - iterator_range 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 - -[heading Synopsis] - - template - struct joint_view; - -[heading Template parameters] - -[table - [[Parameter] [Description] [Default]] - [[`Sequence1`] [A __forward_sequence__] []] - [[`Sequence2`] [A __forward_sequence__] []] -] - -[heading Model of] - -* __forward_sequence__ - -[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 __forward_sequence__. - -[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__ v1(3, 'x'); - __vector__ v2("hello", 123); - joint_view< - __vector__ - , __vector__ - > 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 - -[heading Synopsis] - - template - 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 `joint_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__ vec1; - typedef __vector__ vec2; - vec1 v1(1,2); - vec2 v2('a','b'); - typedef __vector__ sequences; - std::cout << zip_view(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 - -[heading Synopsis] - -[*Unary Version] - - template - struct transform_view; - -[*Binary Version] - - template - 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__::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__::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 - struct result; - - template - struct result - : remove_reference - {}; - - template - T operator()(T x) const - { - return x * x; - } - }; - - typedef __vector__ vector_type; - vector_type vec(2, 5, 3.3); - - transform_view 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 - -[heading Synopsis] - - template - struct reverse_view; - -[heading Template parameters] - -[table - [[Parameter] [Description] [Default]] - [[`Sequence`] [A __bidirectional_sequence__] []] -] - -[heading Model of] - -* __bidirectional_sequence__ - -[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 __bidirectional_sequence__. - -[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__ vector_type; - vector_type vec(2, 5, 3.3); - - reverse_view reverse(vec); - std::cout << reverse << std::endl; - -[endsect] - -[endsect] - -[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]. - -[heading Header] - - #include - -[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 - -[heading Model of] - -* __random_access_sequence__ - -[heading Example] - - std::pair 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 - -[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 vec_c; - fusion::vector2 v(vec_c); - std::cout << __at_c__<0>(v) << std::endl; - std::cout << __at_c__<1>(v) << std::endl; - - v = mpl::vector_c(); - 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 - -[heading Model of] - -* __random_access_sequence__ - -[heading Example] - - boost::array 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 - -[heading Model of] - -* __forward_sequence__ - -[heading Example] - - boost::tuple 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 boost::variant] -This module provides adapters for `boost::variant`. Including the module -header makes `boost::variant` a fully conforming __forward_sequence__. -The variant acts as a sequence of the types that can be contained in the variant. -Accessing types not currently stored int the variant will lead to the variant -being populated with a default constructed value of that type. - -[heading Header] - - #include - -[heading Model of] - -* __forward_sequence__ - -[heading Example] - - boost::variant example_variant = 101; - std::cout << example_variant << '\n'; - *boost::fusion::find(example_variant) = "hello"; - std::cout << example_variant << '\n'; - -[heading See also] - -__boost_variant_library__ - -[endsect] - -[endsect] - -[section Intrinsics] - -Intrinsics form the essential interface of every Fusion __sequence__. __stl__ +Intrinsic form the essential interface of every Fusion __sequence__. __stl__ counterparts of these functions are usually implemented as member functions. Intrinsic functions, unlike __algorithms__, are not generic across the full __sequence__ repertoire. They need to be implemented for @@ -1891,8 +835,7 @@ Performs an element by element swap of the elements in 2 sequences. [*Semantics]: Calls `swap(a1, b1)` for corresponding elements in `seq1` and `seq2`. -[heading Header] - #include +/sequence/intrinsic/swap.hpp> [heading Example] __vector__ v1(1, "hello"), v2(2, "world"); @@ -1930,8 +873,7 @@ Returns the result type of __begin__. [*Semantics]: Returns the type of an iterator to the first element of `Seq`. -[heading Header] - #include +/sequence/intrinsic/begin.hpp> [heading Example] typedef __vector__ vec; @@ -1964,8 +906,7 @@ Returns the result type of __end__. [*Semantics]: Returns the type of an iterator one past the end of `Seq`. -[heading Header] - #include +/sequence/intrinsic/end.hpp> [heading Example] typedef __vector__ vec; @@ -1998,8 +939,7 @@ Returns the result type of __empty__. [*Semantics]: Returns `mpl::true_` if `Seq` has zero elements, `mpl::false_` otherwise. -[heading Header] - #include +/sequence/intrinsic/empty.hpp> [heading Example] typedef __vector__<> empty_vec; @@ -2034,8 +974,7 @@ Returns the result type of __front__. [*Semantics]: The type returned by dereferencing an iterator to the first element in `Seq`. Equivalent to `__result_of_deref__<__result_of_begin__::type>::type`. -[heading Header] - #include +/sequence/intrinsic/front.hpp> [heading Example] typedef __vector__ vec; @@ -2067,8 +1006,7 @@ Returns the result type of __back__. [*Semantics]: The type returned by dereferencing an iterator to the last element in the sequence. Equivalent to `__result_of_deref__<__result_of_prior__<__result_of_end__::type>::type>::type`. -[heading Header] - #include +/sequence/intrinsic/back.hpp> [heading Example] typedef __vector__ vec; @@ -2100,8 +1038,7 @@ Returns the result type of __size__. [*Semantics]: Returns the number of elements in `Seq`. -[heading Header] - #include +/sequence/intrinsic/size.hpp> [heading Example] typedef __vector__ vec; @@ -2141,8 +1078,7 @@ the actual element type, use __result_of_value_at__]. [*Semantics]: Returns the result type of using __at__ to access the `N`th element of `Seq`. -[heading Header] - #include +/sequence/intrinsic/at.hpp> [heading Example] typedef __vector__ vec; @@ -2181,8 +1117,7 @@ get the actual element type, use __result_of_value_at_c__]. [*Semantics]: Returns the result type of using __at_c__ to access the `M`th element of `Seq`. -[heading Header] - #include +/sequence/intrinsic/at.hpp> [heading Example] typedef __vector__ vec; @@ -2218,8 +1153,7 @@ Returns the actual type at a given index from the __sequence__. [*Semantics]: Returns the actual type at the `N`th element of `Seq`. -[heading Header] - #include +/sequence/intrinsic/value_at.hpp> [heading Example] typedef __vector__ vec; @@ -2255,8 +1189,7 @@ Returns the actual type at a given index from the __sequence__. [*Semantics]: Returns the actual type at the `M`th element of `Seq`. -[heading Header] - #include +/sequence/intrinsic/value_at.hpp> [heading Example] typedef __vector__ vec; @@ -2291,8 +1224,7 @@ Returns the result type of __has_key__. [*Semantics]: Returns `mpl::true_` if `Seq` contains an element with key type `Key`, returns `mpl::false_` otherwise. -[heading Header] - #include +/sequence/intrinsic/has_key.hpp> [heading Example] typedef __map__<__pair__, __pair__, __pair__ > mymap; @@ -2332,8 +1264,7 @@ you want to get the actual element type, use __result_of_value_at_key__]. [*Semantics]: Returns the result of using __at_key__ to access the element with key type `Key` in `Seq`. -[heading Header] - #include +/sequence/intrinsic/at_key.hpp> [heading Example] typedef __map__<__pair__, __pair__, __pair__ > mymap; @@ -2369,8 +1300,7 @@ Returns the actual element type associated with a Key from the __sequence__. [*Semantics]: Returns the actual element type associated with key type `Key` in `Seq`. -[heading Header] - #include +/sequence/intrinsic/value_at_key.hpp> [heading Example] typedef __map__<__pair__, __pair__, __pair__ > mymap; @@ -2402,8 +1332,7 @@ Returns the return type of swap. [*Semantics]: Always returns `void`. -[heading Header] - #include +/sequence/intrinsic/swap.hpp> [endsect] @@ -3580,7 +2509,7 @@ __fusion_pair__s. There may be no duplicate __fusion_pair__ key types. [endsect] -[section Operators] +[section Operator] These operators, like the __algorithms__, work generically on all Fusion sequences. All conforming Fusion sequences automatically get these diff --git a/doc/tuples.qbk b/doc/tuple.qbk similarity index 98% rename from doc/tuples.qbk rename to doc/tuple.qbk index 038c8180..1631be25 100644 --- a/doc/tuples.qbk +++ b/doc/tuple.qbk @@ -1,7 +1,8 @@ -[section Tuples] +[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 +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 @@ -22,8 +23,7 @@ in future releases of fusion. typename TN = __unspecified__> class tuple; -[heading Header] - #include +/tuple.hpp> [section Construction] @@ -119,7 +119,7 @@ The __tr1__tuple__ provides the `get` function to provide access to it's element template RJ get(T& t); -[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds. +[*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__::type`. @@ -129,7 +129,7 @@ The __tr1__tuple__ provides the `get` function to provide access to it's element template PJ get(T const& t); -[*Requires]: `0 < I <= N`. The program is ill formed if `I` is out of bounds. +[*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__::type`. diff --git a/doc/view.qbk b/doc/view.qbk new file mode 100644 index 00000000..9c90872f --- /dev/null +++ b/doc/view.qbk @@ -0,0 +1,461 @@ +[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 + +[section single_view] + +`single_view` is a view into a value as a single element sequence. + +[heading Header] + + #include + +[heading Synopsis] + + template + struct single_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`T`] [Any type] []] +] + +[heading Model of] + +* __forward_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 __forward_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 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 + +[heading Synopsis] + + template + 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__ + +[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 __forward_sequence__. + +[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__ vector_type; + + vector_type v("a-string", '@', 987654, true, 6.6); + filter_view > > 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 + +[heading Synopsis] + + template + 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. + +[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 __forward_sequence__. + +[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__ vector_type; + vector_type vec(1, 'x', 3.3, s); + + typedef __result_of_begin__::type A; + typedef __result_of_end__::type B; + typedef __result_of_next__::type C; + typedef __result_of_prior__::type D; + + C c(vec); + D d(vec); + + iterator_range 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 + +[heading Synopsis] + + template + struct joint_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence1`] [A __forward_sequence__] []] + [[`Sequence2`] [A __forward_sequence__] []] +] + +[heading Model of] + +* __forward_sequence__ + +[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 __forward_sequence__. + +[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__ v1(3, 'x'); + __vector__ v2("hello", 123); + joint_view< + __vector__ + , __vector__ + > 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 + +[heading Synopsis] + + template + 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 `joint_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__ vec1; + typedef __vector__ vec2; + vec1 v1(1,2); + vec2 v2('a','b'); + typedef __vector__ sequences; + std::cout << zip_view(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 + +[heading Synopsis] + +[*Unary Version] + + template + struct transform_view; + +[*Binary Version] + + template + 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__::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__::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 + struct result; + + template + struct result + : remove_reference + {}; + + template + T operator()(T x) const + { + return x * x; + } + }; + + typedef __vector__ vector_type; + vector_type vec(2, 5, 3.3); + + transform_view 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 + +[heading Synopsis] + + template + struct reverse_view; + +[heading Template parameters] + +[table + [[Parameter] [Description] [Default]] + [[`Sequence`] [A __bidirectional_sequence__] []] +] + +[heading Model of] + +* __bidirectional_sequence__ + +[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 __bidirectional_sequence__. + +[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__ vector_type; + vector_type vec(2, 5, 3.3); + + reverse_view reverse(vec); + std::cout << reverse << std::endl; + +[endsect] + +[endsect]