diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index 9ad943ee..d902ebe4 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -69,7 +69,7 @@ It is also used to convert sequence into other. [heading Synopsis] template - void copy(Seq1 const& src, Seq2& dest); + typename __result_of_copy__::type copy(Seq1 const& src, Seq2& dest); [table Parameters [[Parameter][Requirement][Description]] @@ -100,6 +100,121 @@ Linear, exactly `__result_of_size__::value`. [endsect] +[section move] + +[heading Description] +move a sequence `src` to a sequence `dest`. +It is also used to convert sequence into other. + +[heading Synopsis] + template + typename __result_of_move__::type move(Seq1&& src, Seq2& dest); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`src`][A model of __forward_sequence__, all elements contained in the `src` sequence should be convertible into the element contained in the `dest` sequence.][Operation's argument]] + [[`dest`][A model of __forward_sequence__, `e2 = std::move(e1)` is valid expression for each pair of elements `e1` of `src` and `e2` of `dest`.][Operation's argument]] +] + +[heading Expression Semantics] + __move__(src, dest); + +[*Return type]: `void` + +[*Semantics]: `e2 = std::move(e1)` for each element `e1` in `src` and `e2` in `dest`. + +[heading Complexity] +Linear, exactly `__result_of_size__::value`. + +[heading Header] + + #include + #include + +[heading Example] + __vector__ vec(1,2); + __list__ ls; + __move__(std::move(vec), ls); + assert(ls == __make_list__(1,2)); + +[endsect] + +[endsect] + +[section Metafunctions] + +[section copy] + +[heading Description] +A metafunction returning the result type of applying __copy__, which is always `void`. + +[heading Synopsis] + template + struct copy + { + typedef void type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]] + [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]] +] + +[heading Expression Semantics] + result_of::copy::type + +[*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence. +Otherwise, none. + +[*Semantics]: Returns the return type of __copy__ for 2 sequences of types `Seq1` and `Seq2`. + +[heading Complexity] +Constant. + +[heading Header] + + #include + #include + +[endsect] + +[section move] + +[heading Description] +A metafunction returning the result type of applying __move__, which is always `void`. + +[heading Synopsis] + template + struct move + { + typedef void type; + }; + +[table Parameters + [[Parameter] [Requirement] [Description]] + [[`Seq1`] [A model of __forward_sequence__] [Operation's argument]] + [[`Seq2`] [A model of __forward_sequence__] [Operation's argument]] +] + +[heading Expression Semantics] + result_of::move::type + +[*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence. +Otherwise, none. + +[*Semantics]: Returns the return type of __move__ for 2 sequences of types `Seq1` and `Seq2`. + +[heading Complexity] +Constant. + +[heading Header] + + #include + #include + +[endsect] + [endsect] [endsect] diff --git a/doc/fusion.qbk b/doc/fusion.qbk index f5d921de..f6c5f654 100644 --- a/doc/fusion.qbk +++ b/doc/fusion.qbk @@ -178,6 +178,8 @@ [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 __swap__ [link fusion.sequence.intrinsic.functions.swap `swap`]] +[def __result_of_swap__ [link fusion.sequence.intrinsic.metafunctions.swap `result_of::swap`]] [def __conversion__ [link fusion.container.conversion.functions Conversion]] [def __result_of_conversion__ [link fusion.container.conversion.metafunctions Conversion Metafunctions]] @@ -226,6 +228,9 @@ [def __algorithm__ [link fusion.algorithm Algorithm]] [def __algorithms__ [link fusion.algorithm Algorithms]] [def __copy__ [link fusion.algorithm.auxiliary.functions.copy `copy`]] +[def __result_of_copy__ [link fusion.algorithm.auxiliary.metafunctions.copy `result_of::copy`]] +[def __move__ [link fusion.algorithm.auxiliary.functions.move `move`]] +[def __result_of_move__ [link fusion.algorithm.auxiliary.metafunctions.move `result_of::move`]] [def __fold__ [link fusion.algorithm.iteration.functions.fold `fold`]] [def __result_of_fold__ [link fusion.algorithm.iteration.metafunctions.fold `result_of::fold`]] [def __reverse_fold__ [link fusion.algorithm.iteration.functions.reverse_fold `reverse_fold`]] diff --git a/doc/html/index.html b/doc/html/index.html index 2279bd54..03b417ee 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -190,7 +190,10 @@
Algorithm
Auxiliary
-
Functions
+
+
Functions
+
Metafunctions
+
Iteration
Functions
diff --git a/doc/sequence.qbk b/doc/sequence.qbk index 40558cb7..2d323e37 100644 --- a/doc/sequence.qbk +++ b/doc/sequence.qbk @@ -854,7 +854,8 @@ Performs an element by element swap of the elements in 2 sequences. [heading Synopsis] template - void swap(Seq1& seq1, Seq2& seq2); + typename __result_of_swap__::type + swap(Seq1& seq1, Seq2& seq2); [heading Parameters] @@ -873,7 +874,10 @@ Performs an element by element swap of the elements in 2 sequences. [*Semantics]: Calls `swap(a1, b1)` for corresponding elements in `seq1` and `seq2`. -/sequence/intrinsic/swap.hpp> +[heading Header] + + #include + #include [heading Example] __vector__ v1(1, "hello"), v2(2, "world"); @@ -1391,7 +1395,7 @@ Returns the actual element type associated with a Key from the __sequence__. [heading Example] typedef __map__<__pair__, __pair__, __pair__ > mymap; - BOOST_MPL_ASSERT((boost::is_same<__result_of_at_key__::type, char>)); + BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at_key__::type, char>)); [endsect] @@ -1415,9 +1419,10 @@ Returns the return type of swap. [heading Expression Semantics] result_of::swap::type -[*Return type]: `void`. +[*Return type]: `void` iff both of `Seq1` and `Seq2` are sequence. +Otherwise, none. -[*Semantics]: Always returns `void`. +[*Semantics]: Returns the return type of __swap__ for 2 sequences of types `Seq1` and `Seq2`. [heading Header] diff --git a/include/boost/fusion/algorithm/auxiliary/copy.hpp b/include/boost/fusion/algorithm/auxiliary/copy.hpp index f8e16e92..683a5c87 100644 --- a/include/boost/fusion/algorithm/auxiliary/copy.hpp +++ b/include/boost/fusion/algorithm/auxiliary/copy.hpp @@ -60,12 +60,19 @@ namespace boost { namespace fusion }; } + namespace result_of + { + template + struct copy + : enable_if, + traits::is_sequence + > > {}; + } + template BOOST_FUSION_GPU_ENABLED - inline typename enable_if, - traits::is_sequence - > >::type + inline typename result_of::copy::type copy(Seq1 const& src, Seq2& dest) { BOOST_STATIC_ASSERT( diff --git a/include/boost/fusion/algorithm/auxiliary/move.hpp b/include/boost/fusion/algorithm/auxiliary/move.hpp index 81fe1d51..76ff4692 100644 --- a/include/boost/fusion/algorithm/auxiliary/move.hpp +++ b/include/boost/fusion/algorithm/auxiliary/move.hpp @@ -60,12 +60,19 @@ namespace boost { namespace fusion }; } + namespace result_of + { + template + struct move + : enable_if, + traits::is_sequence + > > {}; + } + template BOOST_FUSION_GPU_ENABLED - inline typename enable_if, - traits::is_sequence - > >::type + inline typename result_of::move::type move(Seq1&& src, Seq2& dest) { BOOST_STATIC_ASSERT( diff --git a/include/boost/fusion/sequence/intrinsic/swap.hpp b/include/boost/fusion/sequence/intrinsic/swap.hpp index 6eca3146..8c49dc48 100644 --- a/include/boost/fusion/sequence/intrinsic/swap.hpp +++ b/include/boost/fusion/sequence/intrinsic/swap.hpp @@ -14,19 +14,21 @@ #include #include #include -#include #include #include +#include #include namespace boost { namespace fusion { + namespace result_of { template struct swap - { - typedef void type; - }; + : enable_if, + traits::is_sequence + > > {}; } namespace detail @@ -51,7 +53,7 @@ namespace boost { namespace fusion { template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - typename enable_if, traits::is_sequence >, void>::type + inline typename result_of::swap::type swap(Seq1& lhs, Seq2& rhs) { typedef vector references; diff --git a/test/sequence/map_misc.cpp b/test/sequence/map_misc.cpp index 256a16f4..81da9753 100644 --- a/test/sequence/map_misc.cpp +++ b/test/sequence/map_misc.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -148,6 +149,17 @@ test() BOOST_STATIC_ASSERT(!traits::is_sequence::value); } + { // testing mpl::is_sequence + + typedef map, pair, pair > t1; + typedef map<> t2; + typedef map > t3; + + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + } + { // testing mpl compatibility // test an algorithm diff --git a/test/sequence/misc.hpp b/test/sequence/misc.hpp index ecbe1549..c426bba8 100644 --- a/test/sequence/misc.hpp +++ b/test/sequence/misc.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -175,6 +176,17 @@ test() BOOST_STATIC_ASSERT(!traits::is_sequence::value); } + { // testing mpl::is_sequence + + typedef FUSION_SEQUENCE t1; + typedef FUSION_SEQUENCE<> t2; + typedef FUSION_SEQUENCE t3; + + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + BOOST_STATIC_ASSERT(boost::mpl::is_sequence::value); + } + { // testing mpl compatibility // test begin, end, next, prior, advance, size, deref, etc. diff --git a/test/sequence/set.cpp b/test/sequence/set.cpp index 1ea6ba24..cf97c100 100644 --- a/test/sequence/set.cpp +++ b/test/sequence/set.cpp @@ -18,8 +18,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -78,6 +80,28 @@ main() BOOST_TEST(at_key(make_set('X', 123)) == 123); } + { // testing is_sequence + + typedef set t1; + typedef set<> t2; + typedef set t3; + + BOOST_MPL_ASSERT((traits::is_sequence)); + BOOST_MPL_ASSERT((traits::is_sequence)); + BOOST_MPL_ASSERT((traits::is_sequence)); + } + + { // testing mpl::is_sequence + + typedef set t1; + typedef set<> t2; + typedef set t3; + + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + BOOST_MPL_ASSERT((boost::mpl::is_sequence)); + } + return boost::report_errors(); }