result_of::{copy,move,swap} are now SFINAE-friendly

This commit is contained in:
Kohei Takahashi
2014-11-10 14:38:42 +09:00
parent 6314f1a450
commit 465c3f273b
6 changed files with 32 additions and 25 deletions

View File

@ -164,7 +164,8 @@ A metafunction returning the result type of applying __copy__, which is always `
[heading Expression Semantics]
result_of::copy<Seq1, Seq2>::type
[*Return type]: `void`
[*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`.
@ -199,7 +200,8 @@ A metafunction returning the result type of applying __move__, which is always `
[heading Expression Semantics]
result_of::move<Seq1, Seq2>::type
[*Return type]: `void`
[*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`.

View File

@ -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]]

View File

@ -854,7 +854,8 @@ Performs an element by element swap of the elements in 2 sequences.
[heading Synopsis]
template<typename Seq1, typename Seq2>
void swap(Seq1& seq1, Seq2& seq2);
typename __result_of_swap__<Seq1, Seq2>::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 <boost/fusion/sequence/intrinsic/swap.hpp>
#include <boost/fusion/include/swap.hpp>
[heading Example]
__vector__<int, std::string> v1(1, "hello"), v2(2, "world");
@ -1415,9 +1419,10 @@ Returns the return type of swap.
[heading Expression Semantics]
result_of::swap<Seq1, Seq2>::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]

View File

@ -64,17 +64,15 @@ namespace boost { namespace fusion
{
template <typename Seq1, typename Seq2>
struct copy
{
typedef void type;
};
: enable_if<mpl::and_<
traits::is_sequence<Seq1>,
traits::is_sequence<Seq2>
> > {};
}
template <typename Seq1, typename Seq2>
BOOST_FUSION_GPU_ENABLED
inline typename enable_if<mpl::and_<
traits::is_sequence<Seq1>,
traits::is_sequence<Seq2>
> >::type
inline typename result_of::copy<Seq1 const, Seq2>::type
copy(Seq1 const& src, Seq2& dest)
{
BOOST_STATIC_ASSERT(

View File

@ -64,17 +64,15 @@ namespace boost { namespace fusion
{
template <typename Seq1, typename Seq2>
struct move
{
typedef void type;
};
: enable_if<mpl::and_<
traits::is_sequence<Seq1>,
traits::is_sequence<Seq2>
> > {};
}
template <typename Seq1, typename Seq2>
BOOST_FUSION_GPU_ENABLED
inline typename enable_if<mpl::and_<
traits::is_sequence<Seq1>,
traits::is_sequence<Seq2>
> >::type
inline typename result_of::move<Seq1, Seq2>::type
move(Seq1&& src, Seq2& dest)
{
BOOST_STATIC_ASSERT(

View File

@ -14,19 +14,21 @@
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/view/zip_view.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/mpl/and.hpp>
namespace boost { namespace fusion {
namespace result_of
{
template<typename Seq1, typename Seq2>
struct swap
{
typedef void type;
};
: enable_if<mpl::and_<
traits::is_sequence<Seq1>,
traits::is_sequence<Seq2>
> > {};
}
namespace detail
@ -51,7 +53,7 @@ namespace boost { namespace fusion {
template<typename Seq1, typename Seq2>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename enable_if<mpl::and_<traits::is_sequence<Seq1>, traits::is_sequence<Seq2> >, void>::type
inline typename result_of::swap<Seq1, Seq2>::type
swap(Seq1& lhs, Seq2& rhs)
{
typedef vector<Seq1&, Seq2&> references;