From 51d638f51cbbfab282771bbdb31d2d4c691b9751 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 5 Jan 2015 08:19:31 +0900 Subject: [PATCH 01/11] Fix documentation of transform correctly. --- doc/algorithm.qbk | 49 ++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index d902ebe4..1a5bf453 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -2089,32 +2089,33 @@ Constant. [section transform] [heading Description] -For a sequence `seq` and function object or function pointer `f`, `transform` returns a new sequence -with elements created by applying `f(e)` to each element of `e` of `seq`. +Returns the result type of __transform__, given the types of the input sequence and unary __poly_func_obj__. [heading Unary version synopsis] template< typename Sequence, typename F > - typename __result_of_transform__::type transform( - Sequence const& seq, F f); + struct transform + { + typedef __unspecified__ type; + }; [table Parameters [[Parameter][Requirement][Description]] - [[`seq`][A model of __forward_sequence__][Operation's argument]] - [[`f`][`f(e)` is a valid expression for each element `e` of `seq`. `__boost_result_of_call__::type` is the return type of `f` when called with a value of each element type `E`.][Transformation function]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] + [[`F`][A model of unary __poly_func_obj__][Transformation metafunction]] ] [heading Expression Semantics] - __transform__(seq, f); + __result_of_transform__::type [*Return type]: * A model of __forward_sequence__ * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. -[*Semantics]: Returns a new sequence, containing the return values of `f(e)` for each element `e` within `seq`. +[*Semantics]: Returns a sequence that contains the types of `__result_of__::type` for each element `E` within `Sequence`. [heading Binary version synopsis] template< @@ -2122,41 +2123,33 @@ with elements created by applying `f(e)` to each element of `e` of `seq`. typename Sequence2, typename F > - typename __result_of_transform__::type transform( - Sequence1 const& seq1, Sequence2 const& seq2, F f); + struct transform + { + typedef __unspecified__ type; + }; [table Parameters [[Parameter][Requirement][Description]] - [[`seq1`][A model of __forward_sequence__][Operation's argument]] - [[`seq2`][A model of __forward_sequence__][Operation's argument]] - [[`f`][`f(e1,e2)` is a valid expression for each pair of elements `e1` of `seq1` and `e2` of `seq2`. `__boost_result_of_call__::type` is the return type of `f` when called with elements of type `E1` and `E2`][Transformation function]] + [[`Sequence1`][A model of __forward_sequence__][Operation's argument]] + [[`Sequence2`][A model of __forward_sequence__][Operation's argument]] + [[`F`][A model of binary __poly_func_obj__][Transformation metafunction]] ] +[heading Expression Semantics] + __result_of_transform__::type + [*Return type]: A model of __forward_sequence__. -[*Semantics]: Returns a new sequence, containing the return values of `f(e1, e2)` for each pair of elements `e1` and `e2` within `seq1` and `seq2` respectively. +[*Semantics]: Returns a sequence, that contains the types of `__result_of__::type` for each pair of elements `E1` and `E2` within `Sequence1` and `Sequence2` respectively. [heading Complexity] -Constant. Returns a view which is lazily evaluated. +Constant. [heading Header] #include #include -[heading Example] - struct triple - { - typedef int result_type; - - int operator()(int t) const - { - return t * 3; - }; - }; - ... - assert(__transform__(__make_vector__(1,2,3), triple()) == __make_vector__(3,6,9)); - [endsect] [section replace] From a2269f447ed93646cf00735d25a23e4ac2e2539c Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 5 Jan 2015 08:23:21 +0900 Subject: [PATCH 02/11] Fix requirements documentation of replace_if. --- doc/algorithm.qbk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index 1a5bf453..915aecba 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -2193,7 +2193,7 @@ Constant. [section replace_if] [heading Description] -Returns the result type of __replace_if__, given the types of the sequence, __poly_func_obj__ predicate and replacement object. +Returns the result type of __replace_if__, given the types of the sequence, unary __mpl_lambda_expression__ predicate and replacement object. [heading Synopsis] template< @@ -2208,7 +2208,7 @@ Returns the result type of __replace_if__, given the types of the sequence, __po [table Parameters [[Parameter][Requirement][Description]] [[`Sequence`][A model of __forward_sequence__][Operation's argument]] - [[`F`][A model of unary __poly_func_obj__][Replacement predicate]] + [[`F`][A model of unary __mpl_lambda_expression__][Replacement predicate]] [[`T`][Any type][The type of the replacement object]] ] From 85ce2a3eb2ce2c3bfebf56584077dd4cd6c22fa5 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 5 Jan 2015 08:24:14 +0900 Subject: [PATCH 03/11] Fix link of result_of::remove_if. --- doc/algorithm.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index 915aecba..bdcb66bb 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -2258,7 +2258,7 @@ Returns the result type of __remove__, given the sequence and removal types. * A model of __forward_sequence__. * A model of __associative_sequence__ if `Sequence` implements the __associative_sequence__ model. -[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_replace_if__ >::type`. +[*Semantics]: Returns a sequence containing the elements of `Sequence` not of type `T`. Equivalent to `__result_of_remove_if__ >::type`. [heading Complexity] Constant. From 205c0f1eb4c75a73d67a30465525ec9cd5a54dd1 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 12 Jan 2015 23:34:13 +0900 Subject: [PATCH 04/11] update overview of directory structure. --- doc/organization.qbk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/organization.qbk b/doc/organization.qbk index e3dd7fb4..b7166f5d 100644 --- a/doc/organization.qbk +++ b/doc/organization.qbk @@ -36,20 +36,26 @@ link against. * tuple * algorithm + * auxiliary * iteration * query * transformation * adapted + * adt * array - * mpl + * boost::array * boost::tuple + * mpl * std_pair + * std_tuple * struct - * variant * view * filter_view + * flatten_view * iterator_range * joint_view + * nview + * repetitive_view * reverse_view * single_view * transform_view @@ -63,6 +69,9 @@ link against. * generation * mpl * functional + * adapter + * generation + * invocation * sequence * comparison * intrinsic From e572c382f73ac4c40ede2c5fab8eac1e902d6cdd Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Jan 2015 14:57:48 +0900 Subject: [PATCH 05/11] Fixing a broken table notation. --- doc/iterator.qbk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/iterator.qbk b/doc/iterator.qbk index 50430a4d..0aa7b607 100644 --- a/doc/iterator.qbk +++ b/doc/iterator.qbk @@ -67,8 +67,7 @@ the following expressions are valid: ] [heading Expression Semantics] -[ -table +[table [[Expression] [Semantics]] [[`__next__(i)`] [An iterator to the element following `i`]] [[`i == j`] [Iterator equality comparison]] From fbd6a8a50fb6fdbfc67fff1ee278ef9bca0bc76c Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Jan 2015 16:13:12 +0900 Subject: [PATCH 06/11] Fixing template parameter order and a function parameter type. --- doc/iterator.qbk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/iterator.qbk b/doc/iterator.qbk index 0aa7b607..d400003c 100644 --- a/doc/iterator.qbk +++ b/doc/iterator.qbk @@ -417,15 +417,15 @@ Moves an iterator by a specified distance. [heading Synopsis] template< - typename I, - typename M + typename M, + typename I > typename __result_of_advance__::type advance(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] [[`i`] [Model of __forward_iterator__] [Iterator to move relative to]] - [[`N`] [An __mpl_integral_constant__] [Number of positions to move]] + [[`M`] [An __mpl_integral_constant__] [Number of positions to move]] ] [heading Expression Semantics] @@ -454,8 +454,8 @@ Moves an iterator by a specified distance. [heading Synopsis] template< - typename I, - int N + int N, + typename I > typename __result_of_advance_c__::type advance_c(I const& i); @@ -536,7 +536,7 @@ Dereferences an iterator. template< typename I > - typename __result_of_deref__::type operator*(__unspecified__ const& i); + typename __result_of_deref__::type operator*(I const& i); [table Parameters [[Parameter] [Requirement] [Description]] From 0360dc44b24d77c2e806d40dee2fa58bfa8ed423 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Jan 2015 17:48:17 +0900 Subject: [PATCH 07/11] Fix documentation typo of sequence concepts. --- doc/sequence.qbk | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/sequence.qbk b/doc/sequence.qbk index 2d323e37..cf05a53d 100644 --- a/doc/sequence.qbk +++ b/doc/sequence.qbk @@ -249,15 +249,18 @@ any Random Access Sequence the following must be met: [[Expression] [Compile Time Complexity]] [[`__result_of_begin__::type`] [Amortized constant time]] [[`__result_of_end__::type`] [Amortized constant time]] - [[`__result_of_at__::type`] [Amortized constant time]] - [[`__result_of_value_at__::type`] [Amortized constant time]] + [[`__result_of_at__::type`] [Amortized constant time]] + [[`__result_of_at_c__::type`] [Amortized constant time]] + [[`__result_of_value_at__::type`] [Amortized constant time]] + [[`__result_of_value_at_c__::type`] [Amortized constant time]] ] -[blurb __note__ `__result_of_at__` returns the actual type returned by -`__at__(s)`. In most cases, this is a reference. Hence, there is no way to -know the exact element type using `__result_of_at__`.The element at `N` +[blurb __note__ `__result_of_at__` returns the actual type returned by +`__at__(s)`. In most cases, this is a reference. Hence, there is no way to +know the exact element type using `__result_of_at__`.The element at `M` may actually be a reference to begin with. For this purpose, you can use -`__result_of_value_at__`.] +`__result_of_value_at__` (Note that, `__result_of_value_at_c__` +is a counterpart of `__result_of_at_c__` as well).] [heading Expression Semantics] @@ -331,7 +334,7 @@ For any Associative Sequence the following expressions must be valid: by `__at_key__(s)`. In most cases, this is a reference. Hence, there is no way to know the exact element type using `__result_of_at_key__`.The element at `K` may actually be a reference to begin with. For this purpose, -you can use `__result_of_value_at_key__`.] +you can use `__result_of_value_at_key__`.] [heading Expression Semantics] From 28598a791925156f29e54ab2fc327220ccd6871d Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Jan 2015 18:24:44 +0900 Subject: [PATCH 08/11] doc: Plural form and links. --- doc/sequence.qbk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/sequence.qbk b/doc/sequence.qbk index cf05a53d..4722124a 100644 --- a/doc/sequence.qbk +++ b/doc/sequence.qbk @@ -1326,7 +1326,7 @@ Returns the result type of __has_key__. [heading Description] Returns the result type of __at_key__[footnote __result_of_at_key__ -reflects the actual return type of the function __at_key__. __sequence__s +reflects the actual return type of the function __at_key__. __sequence__(s) typically return references to its elements via the __at_key__ function. If you want to get the actual element type, use __result_of_value_at_key__]. @@ -1448,7 +1448,7 @@ operators for free. The I/O operators: `<<` and `>>` work generically on all Fusion sequences. The I/O operators are overloaded in namespace `boost::fusion` -[footnote __sequences__ and __views__ residing in different namespaces +[footnote __sequence__(s) and __views__ residing in different namespaces will have to either provide their own I/O operators (possibly forwarding to fusion's I/O operators) or hoist fusion's I/O operators (using declaration), in their own namespaces for proper argument dependent @@ -1640,7 +1640,7 @@ compile time error. [*Semantics]: For each element, `e1`, in sequence `a`, and for each element, `e2`, in -sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__s, +sequence `b`, `e1 == e2` returns true. For any 2 zero length __sequence__(s), e and f, e == f returns true. [heading Header] From 3955f7651169c8907d7f0fb25ab62b787fc53c00 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 21 Jan 2015 17:27:14 +0900 Subject: [PATCH 09/11] Cosmetic --- doc/algorithm.qbk | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index bdcb66bb..3344d366 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -441,10 +441,10 @@ Linear, exactly `__result_of_size__::value` applications of `F`. [endsect] [section for_each] -A metafunction returning the result type of applying __for_each__ to a sequence. The -return type of __for_each__ is always `void`. [heading Description] +A metafunction returning the result type of applying __for_each__ to a sequence. The +return type of __for_each__ is always `void`. [heading Synopsis] template< @@ -724,8 +724,10 @@ or `__end__(seq)` if there is no such element. [heading Complexity] Linear. At most `__result_of_size__::value` comparisons. -#include -#include +[heading Header] + + #include + #include [heading Example] const __vector__ vec(1.0,2); From b3c560d3b6d062935b1e052c930f4440afe4c973 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 21 Jan 2015 19:34:44 +0900 Subject: [PATCH 10/11] Fix some typos. --- doc/algorithm.qbk | 4 ++-- doc/extension.qbk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index 3344d366..f47fce5c 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -1363,7 +1363,7 @@ Returns a new sequence, with all the elements of the original sequence, except t typename T, typename Sequence > - typename __result_of_remove__::type replace(Sequence const& seq); + typename __result_of_remove__::type remove(Sequence const& seq); [table Parameters [[Parameter][Requirement][Description]] @@ -1832,7 +1832,7 @@ Constant. Returns a view which is lazily evaluated. #include [heading Example] - assert(___pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); + assert(__pop_back__(__make_vector__(1,2,3)) == __make_vector__(1,2)); [endsect] diff --git a/doc/extension.qbk b/doc/extension.qbk index 96e5ef61..cbb61ce5 100644 --- a/doc/extension.qbk +++ b/doc/extension.qbk @@ -323,7 +323,7 @@ For our __random_access_sequence__ we will also need to implement `size_impl`, In order for `example_struct` to serve as an associative forward sequence, we need to adapt the traversal category of our sequence and our iterator accordingly and enable 3 intrinsic sequence lookup features, __at_key__, -__value_at_key__ and __has_key__. We also need to enable 3 iterator lookup +__result_of_value_at_key__ and __has_key__. We also need to enable 3 iterator lookup features, __result_of_key_of__, __result_of_value_of_data__ and __deref_data__. To implement `at_key_impl` we need to associate the `fields::name` and `fields::age` From e4d43b00c1c63059e1cd4323ab99a30d58858420 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 22 Jan 2015 01:02:28 +0900 Subject: [PATCH 11/11] Cosmetic --- doc/fusion.qbk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/fusion.qbk b/doc/fusion.qbk index f6c5f654..829979e6 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -321,10 +321,10 @@ [def __result_of_invoke__ [link fusion.functional.invocation.metafunctions.invoke `result_of::invoke`]] [def __result_of_invoke_procedure__ [link fusion.functional.invocation.metafunctions.invoke_proc `result_of::invoke_procedure`]] [def __result_of_invoke_function_object__ [link fusion.functional.invocation.metafunctions.invoke_fobj `result_of::invoke_function_object`]] -[def __result_of_make_fused__ [link fusion.functional.generation.metafunctions.mk_fused `make_fused`]] -[def __result_of_make_fused_procedure__ [link fusion.functional.generation.metafunctions.mk_fused_proc `make_fused_procedure`]] -[def __result_of_make_fused_function_object__ [link fusion.functional.generation.metafunctions.mk_fused_fobj `make_fused_function_object`]] -[def __result_of_make_unfused__ [link fusion.functional.generation.metafunctions.mk_unfused `make_unfused`]] +[def __result_of_make_fused__ [link fusion.functional.generation.metafunctions.mk_fused `result_of::make_fused`]] +[def __result_of_make_fused_procedure__ [link fusion.functional.generation.metafunctions.mk_fused_proc `result_of::make_fused_procedure`]] +[def __result_of_make_fused_function_object__ [link fusion.functional.generation.metafunctions.mk_fused_fobj `result_of::make_fused_function_object`]] +[def __result_of_make_unfused__ [link fusion.functional.generation.metafunctions.mk_unfused `result_of::make_unfused`]] [def __recursive_inline__ [link fusion.notes.recursive_inlined_functions Recursive Inlined Functions]] [def __overloaded_functions__ [link fusion.notes.overloaded_functions Overloaded Functions]]