mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 12:07:36 +02:00
make find and find_if algorithms segment-aware, stylistic consistency tweaks
[SVN r73892]
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/query/ext_/find_s.hpp>
|
||||
#include <boost/fusion/algorithm/query/find.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
@ -19,21 +19,21 @@ process_tree(Tree const &tree)
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
typedef typename boost::fusion::result_of::find_s<Tree const, short>::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_s<Tree const, float>::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find_s<Tree const, not_there>::type not_there_iter;
|
||||
typedef typename boost::fusion::result_of::find<Tree const, short>::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find<Tree const, float>::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find<Tree const, not_there>::type not_there_iter;
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = fusion::find_s<short>(tree);
|
||||
float_iter fi = fusion::find_s<float>(tree);
|
||||
short_iter si = fusion::find<short>(tree);
|
||||
float_iter fi = fusion::find<float>(tree);
|
||||
|
||||
// they behave like ordinary Fusion iterators ...
|
||||
BOOST_TEST((*si == short('d')));
|
||||
BOOST_TEST((*fi == float(1)));
|
||||
|
||||
// Searching for something that's not there should return the end iterator.
|
||||
not_there_iter nti = fusion::find_s<not_there>(tree);
|
||||
not_there_iter nti = fusion::find<not_there>(tree);
|
||||
BOOST_TEST((nti == fusion::end(tree)));
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
@ -22,21 +22,21 @@ process_tree(Tree const &tree)
|
||||
using namespace boost;
|
||||
using mpl::_;
|
||||
|
||||
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,not_there> >::type not_there_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,not_there> >::type not_there_iter;
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// find_if of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = fusion::find_if_s<is_same<_,short> >(tree);
|
||||
float_iter fi = fusion::find_if_s<is_same<_,float> >(tree);
|
||||
short_iter si = fusion::find_if<is_same<_,short> >(tree);
|
||||
float_iter fi = fusion::find_if<is_same<_,float> >(tree);
|
||||
|
||||
// they behave like ordinary Fusion iterators ...
|
||||
BOOST_TEST((*si == short('d')));
|
||||
BOOST_TEST((*fi == float(1)));
|
||||
|
||||
// Searching for something that's not there should return the end iterator.
|
||||
not_there_iter nti = fusion::find_if_s<is_same<_,not_there> >(tree);
|
||||
not_there_iter nti = fusion::find_if<is_same<_,not_there> >(tree);
|
||||
BOOST_TEST((nti == fusion::end(tree)));
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <sstream>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
|
||||
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
||||
@ -43,16 +43,16 @@ process_tree(Tree const &tree)
|
||||
using namespace fusion;
|
||||
using mpl::_;
|
||||
|
||||
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,short> >::type short_iter;
|
||||
typedef typename boost::fusion::result_of::find_if<Tree const, is_same<_,float> >::type float_iter;
|
||||
|
||||
typedef iterator_range<short_iter, float_iter> slice_t;
|
||||
BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value);
|
||||
|
||||
// find_if_s of a segmented data structure returns generic
|
||||
// find_if of a segmented data structure returns generic
|
||||
// segmented iterators
|
||||
short_iter si = find_if_s<is_same<_,short> >(tree);
|
||||
float_iter fi = find_if_s<is_same<_,float> >(tree);
|
||||
short_iter si = find_if<is_same<_,short> >(tree);
|
||||
float_iter fi = find_if<is_same<_,float> >(tree);
|
||||
|
||||
// If you put them in an iterator range, the range
|
||||
// is automatically a segmented data structure.
|
||||
|
Reference in New Issue
Block a user