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__ 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: diff --git a/doc/view.qbk b/doc/view.qbk index f06705bf..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] @@ -271,7 +270,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 +286,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 +308,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`.]] ] 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; }; }; } 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..fedf733a --- /dev/null +++ b/test/algorithm/ticket-5490.cpp @@ -0,0 +1,41 @@ +/*============================================================================= + 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 +#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()); + + boost::ignore_unused(l, q); +}