From 30c044b03afe130305849b1cefda9b1e6dad80c9 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 5 Jul 2018 22:15:33 +0900 Subject: [PATCH 1/7] doc: Added note regarding IO for adapted type [skip ci] closes: track 6091 --- doc/sequence.qbk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/sequence.qbk b/doc/sequence.qbk index a9fc83d3..4625f8a5 100644 --- a/doc/sequence.qbk +++ b/doc/sequence.qbk @@ -1522,6 +1522,16 @@ each element. Analogously, the global `operator>>` has been overloaded to extract __sequence__(s) from generic input streams by recursively calling `operator>>` for each element. +Please note that, to display your adapted types via fusion IO system, +corresponding overloaded operators should be introduced to same namespace +of the type. + + namespace your_awesome_library + { + using boost::fusion::operators::operator>>; // for input + using boost::fusion::operators::operator<<; // for output + ... + The default delimiter between the elements is space, and the __sequence__ is enclosed in parenthesis. For Example: From 561890429ba2881fb87fe152c07df8b6a13c6e32 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 6 Jul 2018 11:21:54 +0900 Subject: [PATCH 2/7] doc: Moved paragraph `to mpl adaptation` to mpl section --- doc/adapted.qbk | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/adapted.qbk b/doc/adapted.qbk index 7de5586f..d1408619 100644 --- a/doc/adapted.qbk +++ b/doc/adapted.qbk @@ -23,19 +23,6 @@ various data structures, non-intrusively, as full fledged Fusion sequences. #include #include -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. To make Fusion sequences fully conforming __mpl__ sequences, include: - - #include - -If you want bi-directional adaptation to and from __mpl__ and Fusion, simply -include: - - #include - -The header includes all the necessary headers. - [section:array Array] This module provides adapters for arrays. Including the module @@ -145,6 +132,21 @@ header makes all __mpl__ sequences fully conforming fusion sequences. std::cout << __at_c__<0>(v) << std::endl; std::cout << __at_c__<1>(v) << std::endl; +[heading Bi-directional adaptation] + +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. To make Fusion sequences fully conforming __mpl__ sequences, include: + + #include + +If you want bi-directional adaptation to and from __mpl__ and Fusion, simply +include: + + #include + +The header includes all the necessary headers. + [heading See also] __mpl__ From c6448b9e457d619c9184b55aef6e69acccc79b99 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 7 Jul 2018 01:06:05 +0900 Subject: [PATCH 3/7] transform: Stopped use of mpl::apply it causes unintended MPL substitution --- .../detail/apply_transform_result.hpp | 38 ------------------- .../view/transform_view/detail/at_impl.hpp | 16 ++++---- .../view/transform_view/detail/deref_impl.hpp | 15 ++++---- .../transform_view/detail/value_at_impl.hpp | 16 ++++---- .../transform_view/detail/value_of_impl.hpp | 12 +++--- 5 files changed, 27 insertions(+), 70 deletions(-) delete mode 100644 include/boost/fusion/view/transform_view/detail/apply_transform_result.hpp diff --git a/include/boost/fusion/view/transform_view/detail/apply_transform_result.hpp b/include/boost/fusion/view/transform_view/detail/apply_transform_result.hpp deleted file mode 100644 index 87c057f2..00000000 --- a/include/boost/fusion/view/transform_view/detail/apply_transform_result.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - Copyright (c) 2007 Dan Marsden - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(BOOST_FUSION_APPLY_TRANSFORM_RESULT_02092006_1936) -#define BOOST_FUSION_APPLY_TRANSFORM_RESULT_02092006_1936 - -#include -#include - -namespace boost { namespace fusion -{ - struct void_; - - namespace detail - { - template - struct apply_transform_result - { - template - struct apply - : boost::result_of - {}; - - template - struct apply - : boost::result_of - {}; - }; - } -}} - -#endif - - diff --git a/include/boost/fusion/view/transform_view/detail/at_impl.hpp b/include/boost/fusion/view/transform_view/detail/at_impl.hpp index d2045bc2..3723e86a 100644 --- a/include/boost/fusion/view/transform_view/detail/at_impl.hpp +++ b/include/boost/fusion/view/transform_view/detail/at_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,9 +10,8 @@ #define BOOST_FUSION_AT_IMPL_20061029_1946 #include -#include -#include #include +#include namespace boost { namespace fusion { struct transform_view_tag; @@ -29,9 +29,8 @@ namespace boost { namespace fusion { struct apply { typedef typename Seq::transform_type F; - typedef detail::apply_transform_result transform_type; - typedef typename boost::fusion::result_of::at::type value_type; - typedef typename mpl::apply::type type; + typedef typename result_of::at::type value_type; + typedef typename boost::result_of::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Seq& seq) @@ -48,10 +47,9 @@ namespace boost { namespace fusion { struct apply { typedef typename Seq::transform_type F; - typedef detail::apply_transform_result transform_type; - typedef typename boost::fusion::result_of::at::type value1_type; - typedef typename boost::fusion::result_of::at::type value2_type; - typedef typename mpl::apply::type type; + typedef typename result_of::at::type value1_type; + typedef typename result_of::at::type value2_type; + typedef typename boost::result_of::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Seq& seq) diff --git a/include/boost/fusion/view/transform_view/detail/deref_impl.hpp b/include/boost/fusion/view/transform_view/detail/deref_impl.hpp index 646da57c..b94d4a80 100644 --- a/include/boost/fusion/view/transform_view/detail/deref_impl.hpp +++ b/include/boost/fusion/view/transform_view/detail/deref_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,10 +9,8 @@ #define FUSION_DEREF_IMPL_07162005_1026 #include -#include #include -#include -#include +#include namespace boost { namespace fusion { @@ -34,8 +33,8 @@ namespace boost { namespace fusion result_of::deref::type value_type; - typedef detail::apply_transform_result transform_type; - typedef typename mpl::apply::type type; + typedef typename Iterator::transform_type F; + typedef typename boost::result_of::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type @@ -60,8 +59,8 @@ namespace boost { namespace fusion result_of::deref::type value2_type; - typedef detail::apply_transform_result transform_type; - typedef typename mpl::apply::type type; + typedef typename Iterator::transform_type F; + typedef typename boost::result_of::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type @@ -70,7 +69,7 @@ namespace boost { namespace fusion return i.f(*i.first1, *i.first2); } }; - }; + }; } }} diff --git a/include/boost/fusion/view/transform_view/detail/value_at_impl.hpp b/include/boost/fusion/view/transform_view/detail/value_at_impl.hpp index 6875cbed..932dcf63 100644 --- a/include/boost/fusion/view/transform_view/detail/value_at_impl.hpp +++ b/include/boost/fusion/view/transform_view/detail/value_at_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,9 +10,8 @@ #define BOOST_FUSION_VALUE_AT_IMPL_20061101_0745 #include -#include -#include #include +#include namespace boost { namespace fusion { struct transform_view_tag; @@ -29,9 +29,8 @@ namespace boost { namespace fusion { struct apply { typedef typename Seq::transform_type F; - typedef detail::apply_transform_result transform_type; - typedef typename boost::fusion::result_of::value_at::type value_type; - typedef typename mpl::apply::type type; + typedef typename result_of::value_at::type value_type; + typedef typename boost::result_of::type type; }; }; @@ -42,10 +41,9 @@ namespace boost { namespace fusion { struct apply { typedef typename Seq::transform_type F; - typedef detail::apply_transform_result transform_type; - typedef typename boost::fusion::result_of::value_at::type value1_type; - typedef typename boost::fusion::result_of::value_at::type value2_type; - typedef typename mpl::apply::type type; + typedef typename result_of::value_at::type value1_type; + typedef typename result_of::value_at::type value2_type; + typedef typename boost::result_of::type type; }; }; } diff --git a/include/boost/fusion/view/transform_view/detail/value_of_impl.hpp b/include/boost/fusion/view/transform_view/detail/value_of_impl.hpp index ae20cd4b..2bf4a508 100644 --- a/include/boost/fusion/view/transform_view/detail/value_of_impl.hpp +++ b/include/boost/fusion/view/transform_view/detail/value_of_impl.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,9 +9,8 @@ #define FUSION_VALUE_OF_IMPL_07162005_1030 #include -#include #include -#include +#include namespace boost { namespace fusion { @@ -33,8 +33,8 @@ namespace boost { namespace fusion result_of::value_of::type value_type; - typedef detail::apply_transform_result transform_type; - typedef typename mpl::apply::type type; + typedef typename Iterator::transform_type F; + typedef typename boost::result_of::type type; }; }; @@ -52,8 +52,8 @@ namespace boost { namespace fusion result_of::value_of::type value2_type; - typedef detail::apply_transform_result transform_type; - typedef typename mpl::apply::type type; + typedef typename Iterator::transform_type F; + typedef typename boost::result_of::type type; }; }; } From 77959b1d334ba516722bc25c5e4c957f67c92010 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 7 Jul 2018 01:23:11 +0900 Subject: [PATCH 4/7] test: Added test for ticket 5490 --- test/Jamfile | 1 + test/algorithm/ticket-5490.cpp | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/algorithm/ticket-5490.cpp diff --git a/test/Jamfile b/test/Jamfile index 9289033c..c880b984 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -66,6 +66,7 @@ project [ run algorithm/zip2.cpp ] [ run algorithm/zip_ignore.cpp ] [ run algorithm/flatten.cpp ] + [ compile algorithm/ticket-5490.cpp ] [ run sequence/as_deque.cpp ] [ run sequence/as_list.cpp ] diff --git a/test/algorithm/ticket-5490.cpp b/test/algorithm/ticket-5490.cpp new file mode 100644 index 00000000..dee27ef6 --- /dev/null +++ b/test/algorithm/ticket-5490.cpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2018 Kohei Takahashi + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include +#include +#include +#include + +using namespace boost::fusion; + +template +struct predicate {}; + +struct unique {}; + +template +struct meta_func +{ + typedef unique result_type; + + template + unique operator()(const T&) const; +}; + +int main() +{ + vector v; + + typedef predicate lambda_t; + typedef boost::mpl::quote1 quote_t; + + vector l = transform(v, meta_func()); + + vector q = transform(v, meta_func()); +} From c76cd3d6b215d041adbf64b940e6dd741a93e7ff Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 7 Jul 2018 01:27:20 +0900 Subject: [PATCH 5/7] test: Suppress unused warning --- test/algorithm/ticket-5490.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/algorithm/ticket-5490.cpp b/test/algorithm/ticket-5490.cpp index dee27ef6..fedf733a 100644 --- a/test/algorithm/ticket-5490.cpp +++ b/test/algorithm/ticket-5490.cpp @@ -8,6 +8,7 @@ #include #include #include +#include using namespace boost::fusion; @@ -35,4 +36,6 @@ int main() vector l = transform(v, meta_func()); vector q = transform(v, meta_func()); + + boost::ignore_unused(l, q); } From 06a2f0560fe14fb534718e606d14717961295d28 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 7 Jul 2018 01:56:50 +0900 Subject: [PATCH 6/7] doc: Fixed keyword links --- doc/view.qbk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/view.qbk b/doc/view.qbk index f06705bf..c38ebd64 100644 --- a/doc/view.qbk +++ b/doc/view.qbk @@ -271,7 +271,7 @@ defined in the implemented models. [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. +is constructed from a __sequence__ of references to the component `__sequence__`s. [heading Header] @@ -287,7 +287,7 @@ is constructed from a __sequence__ of references to the component __sequence__s. [table [[Parameter] [Description] [Default]] - [[`Sequences`] [A __forward_sequence__ of references to other Fusion __sequence__s] []] + [[`Sequences`] [A __forward_sequence__ of references to other Fusion `__sequence__`s] []] ] [heading Model of] @@ -309,7 +309,7 @@ defined in __forward_sequence__. [table [[Expression] [Semantics]] - [[`ZV(s)`] [Creates a `zip_view` given a sequence of references to the component __sequence__s.]] + [[`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`.]] ] From bd96a6bcfbff59c86600583de1cc7b609528ce93 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 7 Jul 2018 09:24:55 +0900 Subject: [PATCH 7/7] doc: Fixed filter_view parameter requirements --- doc/view.qbk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/view.qbk b/doc/view.qbk index c38ebd64..f39fb7fa 100644 --- a/doc/view.qbk +++ b/doc/view.qbk @@ -93,10 +93,9 @@ presents only those elements for which its predicate evaluates to [heading Template parameters] [table - [[Parameter] [Description] [Default]] - [[`Sequence`] [A __forward_sequence__] []] - [[`Pred`] [Unary Metafunction - returning an `mpl::bool_`] []] + [[Parameter] [Description] [Default]] + [[`Sequence`] [A __forward_sequence__] []] + [[`Pred`] [A unary __mpl_lambda_expression__] []] ] [heading Model of]