mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
continue great segmented Fusion reorg
[SVN r73834]
This commit is contained in:
20
test/Jamfile
20
test/Jamfile
@ -154,18 +154,18 @@ import testing ;
|
||||
# Text for extension features, must be explicitly specified on the command line to be run
|
||||
# TODO these are not in a test-suite because currently test-suites cannot be marked "explicit"
|
||||
|
||||
run algorithm/ext_/for_each_s.cpp ;
|
||||
explicit for_each_s ;
|
||||
run algorithm/segmented_for_each.cpp ;
|
||||
explicit segmented_for_each ;
|
||||
|
||||
run algorithm/ext_/find_s.cpp ;
|
||||
explicit find_s ;
|
||||
run algorithm/segmented_find.cpp ;
|
||||
explicit segmented_find ;
|
||||
|
||||
run algorithm/ext_/find_if_s.cpp ;
|
||||
explicit find_if_s ;
|
||||
run algorithm/segmented_find_if.cpp ;
|
||||
explicit segmented_find_if ;
|
||||
|
||||
run algorithm/ext_/fold_s.cpp ;
|
||||
explicit fold_s ;
|
||||
run algorithm/segmented_fold.cpp ;
|
||||
explicit segmented_fold ;
|
||||
|
||||
run sequence/ext_/iterator_range_s.cpp ;
|
||||
explicit iterator_range_s ;
|
||||
run sequence/segmented_iterator_range.cpp ;
|
||||
explicit segmented_iterator_range ;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
#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/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct not_there {};
|
||||
|
@ -8,10 +8,10 @@
|
||||
#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/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct not_there {};
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/ext_/fold_s.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct write_string
|
||||
{
|
@ -9,7 +9,7 @@
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
#include "../sequence/tree.hpp"
|
||||
|
||||
struct print
|
||||
{
|
@ -5,11 +5,11 @@
|
||||
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 <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/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/ext_/tree.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
||||
#include <boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp>
|
||||
@ -20,7 +20,7 @@
|
||||
#include <boost/mpl/begin.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <sstream>
|
||||
#include "tree.hpp"
|
||||
|
||||
struct ostream_fun
|
||||
{
|
131
test/sequence/tree.hpp
Normal file
131
test/sequence/tree.hpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2006 Eric Niebler
|
||||
|
||||
Use, modification and distribution is subject to 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)
|
||||
==============================================================================*/
|
||||
#ifndef FUSION_BINARY_TREE_EAN_05032006_1027
|
||||
#define FUSION_BINARY_TREE_EAN_05032006_1027
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/view/single_view.hpp>
|
||||
#include <boost/fusion/container/list/cons.hpp> // for nil
|
||||
#include <boost/fusion/container/vector/vector10.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/segments.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/detail/segmented_size.hpp>
|
||||
#include <boost/fusion/support/is_segmented.hpp>
|
||||
#include <boost/fusion/iterator/segmented_iterator.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/detail/segmented_begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/detail/segmented_end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct tree_tag;
|
||||
|
||||
template<typename Data, typename Left = nil, typename Right = nil>
|
||||
struct tree
|
||||
: sequence_base<tree<Data, Left, Right> >
|
||||
{
|
||||
typedef Data data_type;
|
||||
typedef Left left_type;
|
||||
typedef Right right_type;
|
||||
typedef tree_tag fusion_tag;
|
||||
typedef bidirectional_traversal_tag category;
|
||||
typedef mpl::false_ is_view;
|
||||
|
||||
typedef typename mpl::if_<
|
||||
traits::is_sequence<Data>
|
||||
, Data
|
||||
, single_view<Data>
|
||||
>::type data_view;
|
||||
|
||||
explicit tree(
|
||||
typename fusion::detail::call_param<Data>::type data_
|
||||
, typename fusion::detail::call_param<Left>::type left_ = Left()
|
||||
, typename fusion::detail::call_param<Right>::type right_ = Right()
|
||||
)
|
||||
: segments(left_, data_view(data_), right_)
|
||||
{}
|
||||
|
||||
typedef vector3<Left, data_view, Right> segments_type;
|
||||
segments_type segments;
|
||||
};
|
||||
|
||||
template<typename Data>
|
||||
tree<Data> make_tree(Data const &data)
|
||||
{
|
||||
return tree<Data>(data);
|
||||
}
|
||||
|
||||
template<typename Data, typename Left, typename Right>
|
||||
tree<Data, Left, Right> make_tree(Data const &data, Left const &left, Right const &right)
|
||||
{
|
||||
return tree<Data, Left, Right>(data, left, right);
|
||||
}
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template<>
|
||||
struct is_segmented_impl<tree_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply : mpl::true_ {};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct segments_impl<tree_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
is_const<Sequence>
|
||||
, typename Sequence::segments_type const &
|
||||
, typename Sequence::segments_type &
|
||||
>::type type;
|
||||
|
||||
static type call(Sequence &seq)
|
||||
{
|
||||
return seq.segments;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct begin_impl<tree_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: segmented_begin<Sequence>
|
||||
{};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct end_impl<tree_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: segmented_end<Sequence>
|
||||
{};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct size_impl<tree_tag>
|
||||
{
|
||||
template<typename Sequence>
|
||||
struct apply
|
||||
: segmented_size<Sequence>::type
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user