mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 03:57:36 +02:00
@ -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,121 @@ 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` 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 <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` 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 <boost/fusion/algorithm/auxiliary/move.hpp>
|
||||
#include <boost/fusion/include/move.hpp>
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
@ -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`]]
|
||||
|
@ -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>
|
||||
|
@ -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");
|
||||
@ -1391,7 +1395,7 @@ Returns the actual element type associated with a Key from the __sequence__.
|
||||
|
||||
[heading Example]
|
||||
typedef __map__<__pair__<int, char>, __pair__<char, char>, __pair__<double, char> > mymap;
|
||||
BOOST_MPL_ASSERT((boost::is_same<__result_of_at_key__<mymap, int>::type, char>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<__result_of_value_at_key__<mymap, int>::type, char>));
|
||||
|
||||
[endsect]
|
||||
|
||||
@ -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]
|
||||
|
||||
|
@ -60,12 +60,19 @@ namespace boost { namespace fusion
|
||||
};
|
||||
}
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Seq1, typename Seq2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename enable_if<mpl::and_<
|
||||
struct copy
|
||||
: enable_if<mpl::and_<
|
||||
traits::is_sequence<Seq1>,
|
||||
traits::is_sequence<Seq2>
|
||||
> >::type
|
||||
> > {};
|
||||
}
|
||||
|
||||
template <typename Seq1, typename Seq2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::copy<Seq1 const, Seq2>::type
|
||||
copy(Seq1 const& src, Seq2& dest)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
|
@ -60,12 +60,19 @@ namespace boost { namespace fusion
|
||||
};
|
||||
}
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Seq1, typename Seq2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename enable_if<mpl::and_<
|
||||
struct move
|
||||
: enable_if<mpl::and_<
|
||||
traits::is_sequence<Seq1>,
|
||||
traits::is_sequence<Seq2>
|
||||
> >::type
|
||||
> > {};
|
||||
}
|
||||
|
||||
template <typename Seq1, typename Seq2>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::move<Seq1, Seq2>::type
|
||||
move(Seq1&& src, Seq2& dest)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
|
@ -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
|
||||
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;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <string>
|
||||
|
||||
@ -148,6 +149,17 @@ test()
|
||||
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
|
||||
}
|
||||
|
||||
{ // testing mpl::is_sequence
|
||||
|
||||
typedef map<pair<k1, int>, pair<k2, float>, pair<k3, double> > t1;
|
||||
typedef map<> t2;
|
||||
typedef map<pair<k1, char> > t3;
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t1>::value);
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t2>::value);
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t3>::value);
|
||||
}
|
||||
|
||||
{ // testing mpl compatibility
|
||||
|
||||
// test an algorithm
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <string>
|
||||
|
||||
@ -175,6 +176,17 @@ test()
|
||||
BOOST_STATIC_ASSERT(!traits::is_sequence<char>::value);
|
||||
}
|
||||
|
||||
{ // testing mpl::is_sequence
|
||||
|
||||
typedef FUSION_SEQUENCE<int, float, double> t1;
|
||||
typedef FUSION_SEQUENCE<> t2;
|
||||
typedef FUSION_SEQUENCE<char> t3;
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t1>::value);
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t2>::value);
|
||||
BOOST_STATIC_ASSERT(boost::mpl::is_sequence<t3>::value);
|
||||
}
|
||||
|
||||
{ // testing mpl compatibility
|
||||
|
||||
// test begin, end, next, prior, advance, size, deref, etc.
|
||||
|
@ -18,8 +18,10 @@
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@ -78,6 +80,28 @@ main()
|
||||
BOOST_TEST(at_key<int>(make_set('X', 123)) == 123);
|
||||
}
|
||||
|
||||
{ // testing is_sequence
|
||||
|
||||
typedef set<int, float, double> t1;
|
||||
typedef set<> t2;
|
||||
typedef set<char> t3;
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<t1>));
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<t2>));
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<t3>));
|
||||
}
|
||||
|
||||
{ // testing mpl::is_sequence
|
||||
|
||||
typedef set<int, float, double> t1;
|
||||
typedef set<> t2;
|
||||
typedef set<char> t3;
|
||||
|
||||
BOOST_MPL_ASSERT((boost::mpl::is_sequence<t1>));
|
||||
BOOST_MPL_ASSERT((boost::mpl::is_sequence<t2>));
|
||||
BOOST_MPL_ASSERT((boost::mpl::is_sequence<t3>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user