Add result_of::{copy,move}, close #5886

Thanks to: Jamboree
This commit is contained in:
Kohei Takahashi
2014-11-10 14:32:23 +09:00
parent 95d2a111ab
commit 916df63a14
5 changed files with 139 additions and 2 deletions

View File

@ -69,7 +69,7 @@ It is also used to convert sequence into other.
[heading Synopsis]
template <typename Seq1, typename Seq2>
void copy(Seq1 const& src, Seq2& dest);
typename __result_of_copy__<Seq1, Seq2>::type copy(Seq1 const& src, Seq2& dest);
[table Parameters
[[Parameter][Requirement][Description]]
@ -100,6 +100,119 @@ Linear, exactly `__result_of_size__<Sequence>::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 Seq1, typename Seq2>
typename __result_of_move__<Seq1, Seq2>::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__<Sequence>::value`.
[heading Header]
#include <boost/fusion/algorithm/auxiliary/move.hpp>
#include <boost/fusion/include/move.hpp>
[heading Example]
__vector__<int,int> vec(1,2);
__list__<int,int> 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 <typename Seq1, typename Seq2>
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<Seq1, Seq2>::type
[*Return type]: `void`
[*Semantics]: Returns the return type of __copy__ for 2 sequences of types `Seq1` and `Seq2`.
[heading Complexity]
Constant.
[heading Header]
#include <boost/fusion/algorithm/auxiliary/copy.hpp>
#include <boost/fusion/include/copy.hpp>
[endsect]
[section move]
[heading Description]
A metafunction returning the result type of applying __move__, which is always `void`.
[heading Synopsis]
template <typename Seq1, typename Seq2>
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<Seq1, Seq2>::type
[*Return type]: `void`
[*Semantics]: Returns the return type of __move__ for 2 sequences of types `Seq1` and `Seq2`.
[heading Complexity]
Constant.
[heading Header]
#include <boost/fusion/algorithm/auxiliary/move.hpp>
#include <boost/fusion/include/move.hpp>
[endsect]
[endsect]
[endsect]

View File

@ -226,6 +226,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`]]

View File

@ -190,7 +190,10 @@
<dt><span class="section"><a href="fusion/algorithm.html">Algorithm</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/auxiliary.html">Auxiliary</a></span></dt>
<dd><dl><dt><span class="section"><a href="fusion/algorithm/auxiliary/functions.html">Functions</a></span></dt></dl></dd>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/auxiliary/functions.html">Functions</a></span></dt>
<dt><span class="section"><a href="fusion/algorithm/auxiliary/metafunctions.html">Metafunctions</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="fusion/algorithm/iteration.html">Iteration</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="fusion/algorithm/iteration/functions.html">Functions</a></span></dt>

View File

@ -60,6 +60,15 @@ namespace boost { namespace fusion
};
}
namespace result_of
{
template <typename Seq1, typename Seq2>
struct copy
{
typedef void type;
};
}
template <typename Seq1, typename Seq2>
BOOST_FUSION_GPU_ENABLED
inline typename enable_if<mpl::and_<

View File

@ -60,6 +60,15 @@ namespace boost { namespace fusion
};
}
namespace result_of
{
template <typename Seq1, typename Seq2>
struct move
{
typedef void type;
};
}
template <typename Seq1, typename Seq2>
BOOST_FUSION_GPU_ENABLED
inline typename enable_if<mpl::and_<