Compare commits

..

28 Commits

Author SHA1 Message Date
c740a4dbad Merge pull request #188 from boostorg/develop
Post beta merge
2018-07-17 21:12:08 +09:00
bd96a6bcfb doc: Fixed filter_view parameter requirements 2018-07-07 09:24:55 +09:00
2a95fcc3e9 Merge pull request #186 from boostorg/bugfix/apply
Fixed unintentional MPL substitution in transform_view
2018-07-07 08:11:15 +09:00
06a2f0560f doc: Fixed keyword links 2018-07-07 01:56:50 +09:00
c76cd3d6b2 test: Suppress unused warning 2018-07-07 01:27:20 +09:00
77959b1d33 test: Added test for ticket 5490 2018-07-07 01:23:11 +09:00
c6448b9e45 transform: Stopped use of mpl::apply
it causes unintended MPL substitution
2018-07-07 01:06:05 +09:00
561890429b doc: Moved paragraph to mpl adaptation to mpl section 2018-07-06 11:21:54 +09:00
23c54602c2 Merge pull request #185 from boostorg/docfix/io-for-adapted
doc: Added note regarding IO for adapted type
2018-07-05 22:57:56 +09:00
30c044b03a doc: Added note regarding IO for adapted type
[skip ci]
closes: track 6091
2018-07-05 22:15:33 +09:00
a71b9607e1 Merge pull request #184 from boostorg/develop
pre boost 1.68.0 beta merge
2018-07-03 21:50:36 +09:00
102588ae46 Merge pull request #183 from boostorg/mutable_for_each
Fixed for_each parameter type to accept mutable functor
2018-07-03 12:40:54 +09:00
0c138de7cb Merge pull request #180 from boostorg/develop
Merge develop
2018-05-10 00:59:45 +09:00
7899658d8e Merge pull request #175 from boostorg/develop
Post beta merge
2018-03-25 12:58:00 +09:00
03ac9086bc Merge pull request #172 from boostorg/develop
Pre 1.67.0 beta merge - agian
2018-03-06 15:09:50 +09:00
479bc3133b Merge pull request #169 from boostorg/develop
Pre 1.67.0 beta merge
2018-02-26 01:02:16 +09:00
71ad390cf0 Merge pull request #162 from boostorg/develop
Post beta merge
2017-12-03 00:08:31 +09:00
e6b5879511 Merge pull request #157 from boostorg/develop
Merge develop to master
2017-10-31 09:40:44 +09:00
84d8afbb31 Merge pull request #147 from boostorg/develop
Develop to Master
2017-06-19 23:43:44 +09:00
715a7fb729 Merge pull request #141 from boostorg/develop
Boost 1.63.0 beta release
2016-11-01 17:03:05 +09:00
3b96c3b70b Add, and update, documentation build targets. 2016-10-10 11:39:49 -05:00
904d3c2c01 Merge pull request #131 from boostorg/develop
post 1.61.0 beta1
2016-04-02 12:44:16 +08:00
0263c75cd8 Merge pull request #125 from boostorg/develop
Release Candidate for 1.61.0.
2016-03-03 06:58:37 +08:00
53ba3de15a Merge pull request #119 from boostorg/develop
Post 1.60.0 Beta bugfixes.
2015-12-11 15:06:59 +08:00
d6c853f7ad Merge pull request #111 from boostorg/develop
1.60.0 beta
2015-10-28 07:42:24 +08:00
dc55e5e103 Merge pull request #98 from Flast/bugfix/issue-11517
Fix #11517 (for master)
2015-08-04 08:14:48 +08:00
1646a7252b Merge pull request #95 from Flast/preprocess
Regenerate preprocessed files.
2015-07-28 08:03:50 +08:00
dae9964b15 Merge pull request #93 from Flast/bugfix/issue-11140
Fix a issue with nested fusion::tuple.
2015-07-27 15:26:37 +08:00
16 changed files with 127 additions and 214 deletions

View File

@ -23,19 +23,6 @@ various data structures, non-intrusively, as full fledged Fusion sequences.
#include <boost/fusion/adapted.hpp>
#include <boost/fusion/include/adapted.hpp>
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 <boost/fusion/mpl.hpp>
If you want bi-directional adaptation to and from __mpl__ and Fusion, simply
include:
#include <boost/fusion/include/mpl.hpp>
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 <boost/fusion/mpl.hpp>
If you want bi-directional adaptation to and from __mpl__ and Fusion, simply
include:
#include <boost/fusion/include/mpl.hpp>
The header includes all the necessary headers.
[heading See also]
__mpl__

View File

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

View File

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

View File

@ -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 <boost/fusion/support/config.hpp>
#include <boost/utility/result_of.hpp>
namespace boost { namespace fusion
{
struct void_;
namespace detail
{
template <typename F>
struct apply_transform_result
{
template <typename T0, typename T1 = void_>
struct apply
: boost::result_of<F(T0, T1)>
{};
template <typename T0>
struct apply<T0, void_>
: boost::result_of<F(T0)>
{};
};
}
}}
#endif

View File

@ -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 <boost/fusion/support/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/fusion/view/transform_view/detail/apply_transform_result.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/utility/result_of.hpp>
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<F> transform_type;
typedef typename boost::fusion::result_of::at<typename Seq::sequence_type, N>::type value_type;
typedef typename mpl::apply<transform_type, value_type>::type type;
typedef typename result_of::at<typename Seq::sequence_type, N>::type value_type;
typedef typename boost::result_of<F(value_type)>::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<F> transform_type;
typedef typename boost::fusion::result_of::at<typename Seq::sequence1_type, N>::type value1_type;
typedef typename boost::fusion::result_of::at<typename Seq::sequence2_type, N>::type value2_type;
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
typedef typename result_of::at<typename Seq::sequence1_type, N>::type value1_type;
typedef typename result_of::at<typename Seq::sequence2_type, N>::type value2_type;
typedef typename boost::result_of<F(value1_type, value2_type)>::type type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type call(Seq& seq)

View File

@ -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 <boost/fusion/support/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/view/transform_view/detail/apply_transform_result.hpp>
#include <boost/utility/result_of.hpp>
namespace boost { namespace fusion
{
@ -34,8 +33,8 @@ namespace boost { namespace fusion
result_of::deref<typename Iterator::first_type>::type
value_type;
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
typedef typename mpl::apply<transform_type, value_type>::type type;
typedef typename Iterator::transform_type F;
typedef typename boost::result_of<F(value_type)>::type type;
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
@ -60,8 +59,8 @@ namespace boost { namespace fusion
result_of::deref<typename Iterator::first2_type>::type
value2_type;
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
typedef typename Iterator::transform_type F;
typedef typename boost::result_of<F(value1_type, value2_type)>::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);
}
};
};
};
}
}}

View File

@ -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 <boost/fusion/support/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/fusion/view/transform_view/detail/apply_transform_result.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/utility/result_of.hpp>
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<F> transform_type;
typedef typename boost::fusion::result_of::value_at<typename Seq::sequence_type, N>::type value_type;
typedef typename mpl::apply<transform_type, value_type>::type type;
typedef typename result_of::value_at<typename Seq::sequence_type, N>::type value_type;
typedef typename boost::result_of<F(value_type)>::type type;
};
};
@ -42,10 +41,9 @@ namespace boost { namespace fusion {
struct apply
{
typedef typename Seq::transform_type F;
typedef detail::apply_transform_result<F> transform_type;
typedef typename boost::fusion::result_of::value_at<typename Seq::sequence1_type, N>::type value1_type;
typedef typename boost::fusion::result_of::value_at<typename Seq::sequence2_type, N>::type value2_type;
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
typedef typename result_of::value_at<typename Seq::sequence1_type, N>::type value1_type;
typedef typename result_of::value_at<typename Seq::sequence2_type, N>::type value2_type;
typedef typename boost::result_of<F(value1_type, value2_type)>::type type;
};
};
}

View File

@ -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 <boost/fusion/support/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/view/transform_view/detail/apply_transform_result.hpp>
#include <boost/utility/result_of.hpp>
namespace boost { namespace fusion
{
@ -33,8 +33,8 @@ namespace boost { namespace fusion
result_of::value_of<typename Iterator::first_type>::type
value_type;
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
typedef typename mpl::apply<transform_type, value_type>::type type;
typedef typename Iterator::transform_type F;
typedef typename boost::result_of<F(value_type)>::type type;
};
};
@ -52,8 +52,8 @@ namespace boost { namespace fusion
result_of::value_of<typename Iterator::first2_type>::type
value2_type;
typedef detail::apply_transform_result<typename Iterator::transform_type> transform_type;
typedef typename mpl::apply<transform_type, value1_type, value2_type>::type type;
typedef typename Iterator::transform_type F;
typedef typename boost::result_of<F(value1_type, value2_type)>::type type;
};
};
}

View File

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

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 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)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/all.hpp>
@ -29,19 +28,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -72,20 +58,11 @@ main()
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(!boost::fusion::all(t, search_for(1)));
BOOST_TEST(!boost::fusion::all(t, mutable_search_for(1)));
}
{
typedef boost::mpl::vector_c<int, 1, 1, 1> mpl_vec;
typedef boost::mpl::vector_c<int, 1> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1)));
BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2)));
BOOST_TEST(boost::fusion::all(mpl_vec(), mutable_search_for(1)));
BOOST_TEST(!boost::fusion::all(mpl_vec(), mutable_search_for(2)));
}
return boost::report_errors();

View File

@ -2,12 +2,11 @@
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005 Eric Niebler
Copyright (c) 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)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/any.hpp>
@ -30,19 +29,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -58,21 +44,12 @@ main()
BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3));
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::any(t, search_for(1)));
BOOST_TEST(boost::fusion::any(t, mutable_search_for(1)));
}
{
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2)));
BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4)));
BOOST_TEST(boost::fusion::any(mpl_vec(), mutable_search_for(2)));
BOOST_TEST(!boost::fusion::any(mpl_vec(), mutable_search_for(4)));
}
return boost::report_errors();

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2005 Eric Niebler
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 <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/count_if.hpp>
@ -19,29 +18,20 @@ struct bind1st<F<T> > : public F<T>
{
T n;
bind1st(T n) : n(n) { }
bool operator()(T v) { return F<T>::operator()(n, v); }
bool operator()(T v) const { return F<T>::operator()(n, v); }
};
template <typename T>
struct mutable_equal_to : std::equal_to<T>
{
bool operator()(T l, T r) { return std::equal_to<T>::operator()(l, r); }
};
int
main()
{
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(2)) == 1);
BOOST_TEST(boost::fusion::count_if(t, bind1st<mutable_equal_to<double> >(2)) == 1);
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(boost::fusion::count_if(t, bind1st<std::equal_to<double> >(3)) == 0);
BOOST_TEST(boost::fusion::count_if(t, bind1st<mutable_equal_to<double> >(3)) == 0);
}
{
@ -49,7 +39,6 @@ main()
// Cannot use lambda here as mpl iterators return rvalues and lambda needs lvalues
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::greater_equal<int> >(2)) == 2);
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<std::less<int> >(2)) == 1);
BOOST_TEST(boost::fusion::count_if(mpl_vec(), bind1st<mutable_equal_to<int> >(2)) == 1);
}
return boost::report_errors();

View File

@ -1,25 +1,27 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 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)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp>
#include <boost/fusion/algorithm/iteration/accumulate.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <string>
@ -128,7 +130,7 @@ struct functor
}
};
struct mutable_visitor
struct visitor
{
typedef int result_type;
@ -246,7 +248,7 @@ main()
{
boost::fusion::vector<long> vec;
mutable_visitor v;
visitor v;
boost::fusion::fold(vec, 0, v);
}
}

View File

@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2007 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)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/algorithm/query/none.hpp>
@ -29,19 +28,6 @@ namespace
int search;
};
struct mutable_search_for : search_for
{
explicit mutable_search_for(int in_search)
: search_for(in_search)
{}
template <typename T>
bool operator()(T const& v)
{
return search_for::operator()(v);
}
};
}
int
@ -59,24 +45,12 @@ main()
BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3)));
}
{
boost::fusion::vector<int, short, double> t(1, 2, 3.3);
BOOST_TEST(!boost::fusion::none(t, search_for(1)));
BOOST_TEST(boost::fusion::none(t, search_for(3)));
BOOST_TEST(!boost::fusion::none(t, mutable_search_for(1)));
BOOST_TEST(boost::fusion::none(t, mutable_search_for(3)));
}
{
typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
// We cannot use lambda here as mpl vec iterators return
// rvalues, and lambda needs lvalues.
BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4)));
BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3)));
BOOST_TEST(boost::fusion::none(mpl_vec(), mutable_search_for(4)));
BOOST_TEST(!boost::fusion::none(mpl_vec(), mutable_search_for(3)));
}
return boost::report_errors();

View File

@ -1,16 +1,19 @@
/*=============================================================================
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)
==============================================================================*/
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/transformation/replace_if.hpp>
#include <string>
struct gt3
{
@ -21,15 +24,6 @@ struct gt3
}
};
struct mutable_gt3 : gt3
{
template <typename T>
bool operator()(T x)
{
return gt3::operator()(x);
}
};
int
main()
{
@ -48,18 +42,8 @@ main()
{
std::cout << replace_if(t1, gt3(), -456) << std::endl;
BOOST_TEST_EQ(replace_if(t1, gt3(), -456), make_vector(1, 2, -456, -456, s, -456));
}
}
{
char const* s = "Ruby";
typedef vector<int, short, double, long, char const*, float> vector_type;
vector_type t1(1, 2, 3.3, 4, s, 5.5f);
{
std::cout << replace_if(t1, mutable_gt3(), -456) << std::endl;
BOOST_TEST_EQ(replace_if(t1, mutable_gt3(), -456), make_vector(1, 2, -456, -456, s, -456));
BOOST_TEST((replace_if(t1, gt3(), -456)
== make_vector(1, 2, -456, -456, s, -456)));
}
}

View File

@ -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 <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/transform.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/core/ignore_unused.hpp>
using namespace boost::fusion;
template <typename>
struct predicate {};
struct unique {};
template <typename>
struct meta_func
{
typedef unique result_type;
template <typename T>
unique operator()(const T&) const;
};
int main()
{
vector<int> v;
typedef predicate<boost::mpl::_1> lambda_t;
typedef boost::mpl::quote1<predicate> quote_t;
vector<unique> l = transform(v, meta_func<lambda_t>());
vector<unique> q = transform(v, meta_func<quote_t>());
boost::ignore_unused(l, q);
}