From 9b26b4a0f71fd2d723c900754a6f7c033aab5d36 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Sun, 25 Oct 2009 22:59:54 +0000 Subject: [PATCH] associative iterators & views [SVN r57156] --- .../algorithm/iteration/detail/fold.hpp | 2 +- .../algorithm/query/detail/assoc_find.hpp | 35 ----- .../fusion/algorithm/query/detail/find_if.hpp | 26 +--- include/boost/fusion/algorithm/query/find.hpp | 33 +++-- .../boost/fusion/algorithm/query/find_if.hpp | 35 ++--- .../algorithm/transformation/erase_key.hpp | 11 +- .../boost/fusion/container/deque/deque.hpp | 1 + .../container/map/detail/at_key_impl.hpp | 49 ------- .../container/map/detail/begin_impl.hpp | 69 ++++----- .../container/map/detail/deref_data_impl.hpp | 48 +++++++ .../container/map/detail/deref_impl.hpp | 45 ++++++ .../fusion/container/map/detail/end_impl.hpp | 66 ++++----- .../container/map/detail/key_of_impl.hpp | 32 +++++ .../container/map/detail/lookup_key.hpp | 99 ------------- .../container/map/detail/map_lookup.hpp | 128 ----------------- .../map/detail/value_at_key_impl.hpp | 33 ----- .../map/detail/value_of_data_impl.hpp | 32 +++++ .../container/map/detail/value_of_impl.hpp | 39 +++++ include/boost/fusion/container/map/map.hpp | 10 +- .../boost/fusion/container/map/map_fwd.hpp | 2 + .../container/set/detail/at_key_impl.hpp | 49 ------- .../container/set/detail/begin_impl.hpp | 69 ++++----- .../container/set/detail/deref_data_impl.hpp | 24 ++++ .../container/set/detail/deref_impl.hpp | 45 ++++++ .../fusion/container/set/detail/end_impl.hpp | 66 ++++----- .../container/set/detail/key_of_impl.hpp | 24 ++++ .../container/set/detail/lookup_key.hpp | 93 ------------ .../container/set/detail/set_lookup.hpp | 128 ----------------- .../set/detail/value_at_key_impl.hpp | 35 ----- .../set/detail/value_of_data_impl.hpp | 24 ++++ .../container/set/detail/value_of_impl.hpp | 34 +++++ include/boost/fusion/container/set/set.hpp | 10 +- .../boost/fusion/container/set/set_fwd.hpp | 2 + .../boost/fusion/iterator/basic_iterator.hpp | 136 ++++++++++++++++++ include/boost/fusion/iterator/deref_data.hpp | 49 +++++++ .../boost/fusion/iterator/iterator_facade.hpp | 3 +- include/boost/fusion/iterator/key_of.hpp | 42 ++++++ .../boost/fusion/iterator/value_of_data.hpp | 42 ++++++ .../fusion/sequence/intrinsic/at_key.hpp | 21 ++- .../fusion/sequence/intrinsic/has_key.hpp | 16 ++- .../sequence/intrinsic/value_at_key.hpp | 10 +- .../view/filter_view/detail/begin_impl.hpp | 5 +- .../filter_view/detail/deref_data_impl.hpp | 37 +++++ .../view/filter_view/detail/end_impl.hpp | 5 +- .../view/filter_view/detail/key_of_impl.hpp | 28 ++++ .../view/filter_view/detail/next_impl.hpp | 21 ++- .../filter_view/detail/value_of_data_impl.hpp | 28 ++++ .../fusion/view/filter_view/filter_view.hpp | 12 +- .../view/filter_view/filter_view_iterator.hpp | 28 +++- .../view/iterator_range/iterator_range.hpp | 1 - .../view/joint_view/detail/begin_impl.hpp | 5 +- .../joint_view/detail/deref_data_impl.hpp | 37 +++++ .../view/joint_view/detail/key_of_impl.hpp | 28 ++++ .../view/joint_view/detail/next_impl.hpp | 5 +- .../joint_view/detail/value_of_data_impl.hpp | 28 ++++ .../fusion/view/joint_view/joint_view.hpp | 14 +- .../view/joint_view/joint_view_iterator.hpp | 9 +- .../reverse_view/detail/deref_data_impl.hpp | 37 +++++ .../view/reverse_view/detail/key_of_impl.hpp | 28 ++++ .../detail/value_of_data_impl.hpp | 28 ++++ .../fusion/view/reverse_view/reverse_view.hpp | 12 +- .../reverse_view/reverse_view_iterator.hpp | 3 + test/algorithm/erase_key.cpp | 4 +- test/sequence/as_set.cpp | 2 +- test/sequence/filter_view.cpp | 39 ++--- test/sequence/iterator_range.cpp | 33 +++++ test/sequence/joint_view.cpp | 45 +++++- test/sequence/map.cpp | 16 +++ test/sequence/set.cpp | 18 ++- 69 files changed, 1331 insertions(+), 942 deletions(-) delete mode 100644 include/boost/fusion/algorithm/query/detail/assoc_find.hpp delete mode 100644 include/boost/fusion/container/map/detail/at_key_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/deref_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/key_of_impl.hpp delete mode 100644 include/boost/fusion/container/map/detail/lookup_key.hpp delete mode 100644 include/boost/fusion/container/map/detail/map_lookup.hpp delete mode 100644 include/boost/fusion/container/map/detail/value_at_key_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/value_of_impl.hpp delete mode 100644 include/boost/fusion/container/set/detail/at_key_impl.hpp create mode 100644 include/boost/fusion/container/set/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/container/set/detail/deref_impl.hpp create mode 100644 include/boost/fusion/container/set/detail/key_of_impl.hpp delete mode 100644 include/boost/fusion/container/set/detail/lookup_key.hpp delete mode 100644 include/boost/fusion/container/set/detail/set_lookup.hpp delete mode 100644 include/boost/fusion/container/set/detail/value_at_key_impl.hpp create mode 100644 include/boost/fusion/container/set/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/container/set/detail/value_of_impl.hpp create mode 100644 include/boost/fusion/iterator/basic_iterator.hpp create mode 100644 include/boost/fusion/iterator/deref_data.hpp create mode 100644 include/boost/fusion/iterator/key_of.hpp create mode 100644 include/boost/fusion/iterator/value_of_data.hpp create mode 100644 include/boost/fusion/view/filter_view/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/view/filter_view/detail/key_of_impl.hpp create mode 100644 include/boost/fusion/view/filter_view/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/view/joint_view/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/view/joint_view/detail/key_of_impl.hpp create mode 100644 include/boost/fusion/view/joint_view/detail/value_of_data_impl.hpp create mode 100644 include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp create mode 100644 include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp create mode 100644 include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 8d305865..62a677de 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -56,7 +56,7 @@ namespace detail { typedef typename static_fold< - typename result_of::next::type + typename result_of::next::type , Last , typename fold_apply::type , F diff --git a/include/boost/fusion/algorithm/query/detail/assoc_find.hpp b/include/boost/fusion/algorithm/query/detail/assoc_find.hpp deleted file mode 100644 index 7591405f..00000000 --- a/include/boost/fusion/algorithm/query/detail/assoc_find.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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(FUSION_ASSOC_FIND_09242005_1133) -#define FUSION_ASSOC_FIND_09242005_1133 - -#include -#include -#include - -namespace boost { namespace fusion { namespace detail -{ - template - struct assoc_find - { - typedef typename - mpl::if_< - is_const - , typename Sequence::template meta_find_impl_const::type - , typename Sequence::template meta_find_impl::type - >::type - type; - - static type - call(Sequence& s) - { - return s.find_impl(mpl::identity()); - } - }; -}}} - -#endif diff --git a/include/boost/fusion/algorithm/query/detail/find_if.hpp b/include/boost/fusion/algorithm/query/detail/find_if.hpp index cf0cc6b7..5d2a7419 100644 --- a/include/boost/fusion/algorithm/query/detail/find_if.hpp +++ b/include/boost/fusion/algorithm/query/detail/find_if.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2007 Dan Marsden + Copyright (c) 2009 Christopher Schmidt 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) @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -31,7 +31,7 @@ namespace detail struct apply_filter { typedef typename mpl::apply1< - Pred, typename result_of::value_of::type>::type type; + Pred, Iterator>::type type; BOOST_STATIC_CONSTANT(int, value = type::value); }; @@ -85,7 +85,7 @@ namespace detail typedef typename mpl::apply1< Pred - , typename result_of::value_of::type + , Shifted >::type type; BOOST_STATIC_CONSTANT(int, value = type::value); @@ -227,26 +227,6 @@ namespace detail return choose_call(iter, typename traits::category_of::type()); } }; - - template - struct static_seq_find_if : static_find_if - { - typedef typename static_find_if::type type; - - template - static type - call(Sequence const& seq) - { - return static_find_if::call(fusion::begin(seq)); - } - - template - static type - call(Sequence& seq) - { - return static_find_if::call(fusion::begin(seq)); - } - }; }}} #endif diff --git a/include/boost/fusion/algorithm/query/find.hpp b/include/boost/fusion/algorithm/query/find.hpp index ece8cdd6..8816c9a5 100644 --- a/include/boost/fusion/algorithm/query/find.hpp +++ b/include/boost/fusion/algorithm/query/find.hpp @@ -8,10 +8,12 @@ #define FUSION_FIND_05052005_1107 #include -#include #include #include +#include +#include #include +#include #include #include #include @@ -25,29 +27,26 @@ namespace boost { namespace fusion template < typename Sequence , typename T - , bool is_associative_sequence = traits::is_associative::value > - struct find; - - template - struct find + > + struct find { typedef - detail::static_seq_find_if< + detail::static_find_if< typename result_of::begin::type , typename result_of::end::type - , is_same + , is_same< + typename mpl::if_< + traits::is_associative + , key_of + , value_of + >::type + , T + > > filter; typedef typename filter::type type; }; - - template - struct find - { - typedef detail::assoc_find filter; - typedef typename filter::type type; - }; } template @@ -59,7 +58,7 @@ namespace boost { namespace fusion find(Sequence& seq) { typedef typename result_of::find::filter filter; - return filter::call(seq); + return filter::call(fusion::begin(seq)); } template @@ -67,7 +66,7 @@ namespace boost { namespace fusion find(Sequence const& seq) { typedef typename result_of::find::filter filter; - return filter::call(seq); + return filter::call(fusion::begin(seq)); } }} diff --git a/include/boost/fusion/algorithm/query/find_if.hpp b/include/boost/fusion/algorithm/query/find_if.hpp index 4340d688..6b96cc71 100644 --- a/include/boost/fusion/algorithm/query/find_if.hpp +++ b/include/boost/fusion/algorithm/query/find_if.hpp @@ -10,6 +10,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -20,13 +24,18 @@ namespace boost { namespace fusion template struct find_if { - typedef typename + typedef detail::static_find_if< typename result_of::begin::type , typename result_of::end::type - , Pred - >::type - type; + , mpl::bind1< + typename mpl::lambda::type + , mpl::bind1,mpl::_1> + > + > + filter; + + typedef typename filter::type type; }; } @@ -38,14 +47,7 @@ namespace boost { namespace fusion >::type find_if(Sequence& seq) { - typedef - detail::static_find_if< - typename result_of::begin::type - , typename result_of::end::type - , Pred - > - filter; - + typedef typename result_of::find_if::filter filter; return filter::call(fusion::begin(seq)); } @@ -53,14 +55,7 @@ namespace boost { namespace fusion inline typename result_of::find_if::type const find_if(Sequence const& seq) { - typedef - detail::static_find_if< - typename result_of::begin::type - , typename result_of::end::type - , Pred - > - filter; - + typedef typename result_of::find_if::filter filter; return filter::call(fusion::begin(seq)); } }} diff --git a/include/boost/fusion/algorithm/transformation/erase_key.hpp b/include/boost/fusion/algorithm/transformation/erase_key.hpp index dcdc6f09..03128695 100644 --- a/include/boost/fusion/algorithm/transformation/erase_key.hpp +++ b/include/boost/fusion/algorithm/transformation/erase_key.hpp @@ -7,7 +7,7 @@ #if !defined(FUSION_ERASE_KEY_10022005_1851) #define FUSION_ERASE_KEY_10022005_1851 -#include +#include #include #include #include @@ -18,18 +18,15 @@ namespace boost { namespace fusion { template struct erase_key - { - typedef detail::assoc_find filter; - typedef typename erase::type type; - }; + : erase::type> + {}; } template inline typename result_of::erase_key::type erase_key(Sequence const& seq) { - typedef typename result_of::erase_key::filter filter; - return erase(seq, filter::call(seq)); + return erase(seq, find(seq)); } }} diff --git a/include/boost/fusion/container/deque/deque.hpp b/include/boost/fusion/container/deque/deque.hpp index 27d9ce78..01f017e9 100644 --- a/include/boost/fusion/container/deque/deque.hpp +++ b/include/boost/fusion/container/deque/deque.hpp @@ -45,6 +45,7 @@ namespace boost { namespace fusion { sequence_base > { typedef deque_tag fusion_tag; + typedef bidirectional_traversal_tag category; typedef typename detail::deque_keyed_values::type base; typedef typename detail::deque_initial_size::type size; typedef mpl::int_ next_up; diff --git a/include/boost/fusion/container/map/detail/at_key_impl.hpp b/include/boost/fusion/container/map/detail/at_key_impl.hpp deleted file mode 100644 index 8b0d70aa..00000000 --- a/include/boost/fusion/container/map/detail/at_key_impl.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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(FUSION_AT_KEY_IMPL_05222005_0254) -#define FUSION_AT_KEY_IMPL_05222005_0254 - -#include -#include -#include - -namespace boost { namespace fusion -{ - struct map_tag; - - namespace extension - { - template - struct at_key_impl; - - template <> - struct at_key_impl - { - template - struct apply - { - typedef typename Sequence::template meta_at_impl element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - static type - call(Sequence& m) - { - return m.at_impl(mpl::identity()); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/container/map/detail/begin_impl.hpp b/include/boost/fusion/container/map/detail/begin_impl.hpp index 5fe25caf..063932a8 100644 --- a/include/boost/fusion/container/map/detail/begin_impl.hpp +++ b/include/boost/fusion/container/map/detail/begin_impl.hpp @@ -1,56 +1,43 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2009 Christopher Schmidt - Distributed under the Boost Software License, Version 1.0. (See accompanying + 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(FUSION_BEGIN_IMPL_05222005_1108) -#define FUSION_BEGIN_IMPL_05222005_1108 -#include -#include -#include -#include +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct map_tag; + template + struct begin_impl; - namespace extension + template <> + struct begin_impl { - template - struct begin_impl; - - template <> - struct begin_impl + template + struct apply { - template - struct apply + typedef + basic_iterator< + map_iterator_tag + , typename Seq::category + , Seq + , 0 + > + type; + + static type + call(Seq& seq) { - typedef typename - result_of::begin::type - iterator_type; - - typedef typename - result_of::begin::type - const_iterator_type; - - typedef typename - mpl::eval_if< - is_const - , mpl::identity - , mpl::identity - >::type - type; - - static type - call(Sequence& m) - { - return fusion::begin(m.get_data()); - } - }; + return type(seq,0); + } }; - } -}} + }; +}}} #endif diff --git a/include/boost/fusion/container/map/detail/deref_data_impl.hpp b/include/boost/fusion/container/map/detail/deref_data_impl.hpp new file mode 100644 index 00000000..9943171a --- /dev/null +++ b/include/boost/fusion/container/map/detail/deref_data_impl.hpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + { + template + struct apply + { + typedef typename result_of::value_of::type::second_type data; + + typedef typename + mpl::eval_if< + is_const + , detail::cref_result > + , detail::ref_result > + >::type + type; + + static type + call(It const& it) + { + return deref(it).second; + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/deref_impl.hpp b/include/boost/fusion/container/map/detail/deref_impl.hpp new file mode 100644 index 00000000..359a5dc0 --- /dev/null +++ b/include/boost/fusion/container/map/detail/deref_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP + +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_impl; + + template <> + struct deref_impl + { + template + struct apply + { + typedef typename + result_of::at< + typename mpl::if_< + is_const + , typename It::seq_type::storage_type const + , typename It::seq_type::storage_type + >::type + , typename It::index + >::type + type; + + static type + call(It const& it) + { + return at(it.seq->get_data()); + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/end_impl.hpp b/include/boost/fusion/container/map/detail/end_impl.hpp index 0cafc92c..0e30de8c 100644 --- a/include/boost/fusion/container/map/detail/end_impl.hpp +++ b/include/boost/fusion/container/map/detail/end_impl.hpp @@ -1,53 +1,43 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2009 Christopher Schmidt - Distributed under the Boost Software License, Version 1.0. (See accompanying + 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(FUSION_END_IMPL_05222005_1108) -#define FUSION_END_IMPL_05222005_1108 -#include +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct map_tag; + template + struct end_impl; - namespace extension + template <> + struct end_impl { - template - struct end_impl; - - template <> - struct end_impl + template + struct apply { - template - struct apply + typedef + basic_iterator< + map_iterator_tag + , typename Seq::category + , Seq + , Seq::size::value + > + type; + + static type + call(Seq& seq) { - typedef typename - result_of::end::type - iterator_type; - - typedef typename - result_of::end::type - const_iterator_type; - - typedef typename - mpl::eval_if< - is_const - , mpl::identity - , mpl::identity - >::type - type; - - static type - call(Sequence& m) - { - return fusion::end(m.get_data()); - } - }; + return type(seq,0); + } }; - } -}} + }; +}}} #endif diff --git a/include/boost/fusion/container/map/detail/key_of_impl.hpp b/include/boost/fusion/container/map/detail/key_of_impl.hpp new file mode 100644 index 00000000..5a90c037 --- /dev/null +++ b/include/boost/fusion/container/map/detail/key_of_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + { + typedef typename + value_of_impl:: + template apply::type::first_type + type; + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/lookup_key.hpp b/include/boost/fusion/container/map/detail/lookup_key.hpp deleted file mode 100644 index 17774362..00000000 --- a/include/boost/fusion/container/map/detail/lookup_key.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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(FUSION_LOOKUP_KEY_07222005_1248) -#define FUSION_LOOKUP_KEY_07222005_1248 - -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct void_; -}} - -namespace boost { namespace fusion { namespace detail -{ - template - struct map_data_type - { - typedef typename - add_reference< - typename T::second_type - >::type - type; - }; - - template <> - struct map_data_type - { - typedef void_& type; - }; - - template - struct map_const_data_type - { - typedef typename - add_reference< - typename add_const< - typename T::second_type - >::type - >::type - type; - }; - - template <> - struct map_const_data_type - { - typedef void_ const& type; - }; - - template - struct map_value_type - { - typedef typename T::second_type type; - }; - - template <> - struct map_value_type - { - typedef void_ type; - }; - - template - struct map_key_type - { - typedef typename T::first_type type; - }; - - template - struct map_key_type - { - typedef unknown_key type; - }; - - template - struct map_lookup_key - { - static RT - call(Vector& vec) - { - return vec.at_impl(mpl::int_()).second; - } - }; - - template - struct map_lookup_key, Vector> - { - static void_& - call(Vector& vec); // intentionally undefined - }; -}}} - -#endif - diff --git a/include/boost/fusion/container/map/detail/map_lookup.hpp b/include/boost/fusion/container/map/detail/map_lookup.hpp deleted file mode 100644 index 2f792cbd..00000000 --- a/include/boost/fusion/container/map/detail/map_lookup.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#if !defined(FUSION_MAP_LOOKUP_07212005_1118) -#define FUSION_MAP_LOOKUP_07212005_1118 - -#include -#include -#include -#include -#include - -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310) -#pragma warning (push) -#pragma warning(disable: 4348) // redefinition of default parameter -#endif - - template - struct meta_at_impl - { - typedef void_ type; - }; - - template - struct meta_find_impl - { - typedef vector_iterator type; - }; - - template - struct meta_find_impl_const - { - typedef vector_iterator type; - }; - - template - vector_iterator - find_impl(mpl::identity) const - { - return vector_iterator(data); - } - - template - vector_iterator - find_impl(mpl::identity) - { - return vector_iterator(data); - } - -#define BOOST_PP_FILENAME_1 \ - -#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_MAP_SIZE)) -#include BOOST_PP_ITERATE() - -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310) -#pragma warning (pop) -#endif - -#endif -#else // defined(BOOST_PP_IS_ITERATING) -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// - -#define N BOOST_PP_ITERATION() - - template - struct meta_at_impl< - typename detail::map_key_type::type, dummy> - { - typedef typename detail::map_value_type::type type; - }; - - typename detail::map_data_type::type - at_impl(mpl::identity::type>) - { - return detail::map_lookup_key< - N - , typename detail::map_data_type::type - , typename detail::map_key_type::type - , storage_type>::call(data); - } - - typename detail::map_const_data_type::type - at_impl(mpl::identity::type>) const - { - return detail::map_lookup_key< - N - , typename detail::map_const_data_type::type - , typename detail::map_key_type::type - , storage_type const>::call(data); - } - - template - struct meta_find_impl< - typename detail::map_key_type::type, dummy> - { - typedef vector_iterator type; - }; - - template - struct meta_find_impl_const< - typename detail::map_key_type::type, dummy> - { - typedef vector_iterator type; - }; - - vector_iterator - find_impl(mpl::identity::type>) - { - return vector_iterator(data); - } - - vector_iterator - find_impl(mpl::identity::type>) const - { - return vector_iterator(data); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - diff --git a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp deleted file mode 100644 index 6c516462..00000000 --- a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2006 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(FUSION_VALUE_AT_KEY_IMPL_05222005_0325) -#define FUSION_VALUE_AT_KEY_IMPL_05222005_0325 - -namespace boost { namespace fusion -{ - struct map_tag; - - namespace extension - { - template - struct value_at_key_impl; - - template <> - struct value_at_key_impl - { - template - struct apply - { - typedef typename Sequence:: - template meta_at_impl::type type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/container/map/detail/value_of_data_impl.hpp b/include/boost/fusion/container/map/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..28d21678 --- /dev/null +++ b/include/boost/fusion/container/map/detail/value_of_data_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + { + template + struct apply + { + typedef typename + value_of_impl:: + template apply::type::second_type + type; + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/value_of_impl.hpp b/include/boost/fusion/container/map/detail/value_of_impl.hpp new file mode 100644 index 00000000..26b19f20 --- /dev/null +++ b/include/boost/fusion/container/map/detail/value_of_impl.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP + +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_impl; + + template <> + struct value_of_impl + { + template + struct apply + { + typedef typename + result_of::value_at< + typename mpl::if_< + is_const + , typename It::seq_type::storage_type const + , typename It::seq_type::storage_type + >::type + , typename It::index + >::type + type; + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/map.hpp b/include/boost/fusion/container/map/map.hpp index 5f5fb1cc..1ecd906f 100644 --- a/include/boost/fusion/container/map/map.hpp +++ b/include/boost/fusion/container/map/map.hpp @@ -11,11 +11,13 @@ #include #include #include -#include #include #include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -23,7 +25,6 @@ namespace boost { namespace fusion { struct void_; - struct map_tag; struct fusion_sequence_tag; template @@ -49,7 +50,6 @@ namespace boost { namespace fusion : data(rhs) {} #include - #include template map& diff --git a/include/boost/fusion/container/map/map_fwd.hpp b/include/boost/fusion/container/map/map_fwd.hpp index 660466bd..d8a9c1b7 100644 --- a/include/boost/fusion/container/map/map_fwd.hpp +++ b/include/boost/fusion/container/map/map_fwd.hpp @@ -13,6 +13,8 @@ namespace boost { namespace fusion { struct void_; + struct map_tag; + struct map_iterator_tag; template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( diff --git a/include/boost/fusion/container/set/detail/at_key_impl.hpp b/include/boost/fusion/container/set/detail/at_key_impl.hpp deleted file mode 100644 index d0c1de00..00000000 --- a/include/boost/fusion/container/set/detail/at_key_impl.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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(FUSION_AT_KEY_IMPL_09162005_1118) -#define FUSION_AT_KEY_IMPL_09162005_1118 - -#include -#include -#include - -namespace boost { namespace fusion -{ - struct set_tag; - - namespace extension - { - template - struct at_key_impl; - - template <> - struct at_key_impl - { - template - struct apply - { - typedef typename Sequence::template meta_at_impl element; - - typedef typename - mpl::eval_if< - is_const - , detail::cref_result - , detail::ref_result - >::type - type; - - static type - call(Sequence& s) - { - return s.at_impl(mpl::identity()); - } - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/container/set/detail/begin_impl.hpp b/include/boost/fusion/container/set/detail/begin_impl.hpp index 9b42df72..8047743d 100644 --- a/include/boost/fusion/container/set/detail/begin_impl.hpp +++ b/include/boost/fusion/container/set/detail/begin_impl.hpp @@ -1,56 +1,43 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2009 Christopher Schmidt - Distributed under the Boost Software License, Version 1.0. (See accompanying + 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(FUSION_BEGIN_IMPL_09162005_1120) -#define FUSION_BEGIN_IMPL_09162005_1120 -#include -#include -#include -#include +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct set_tag; + template + struct begin_impl; - namespace extension + template <> + struct begin_impl { - template - struct begin_impl; - - template <> - struct begin_impl + template + struct apply { - template - struct apply + typedef + basic_iterator< + set_iterator_tag + , typename Seq::category + , Seq + , 0 + > + type; + + static type + call(Seq& seq) { - typedef typename - result_of::begin::type - iterator_type; - - typedef typename - result_of::begin::type - const_iterator_type; - - typedef typename - mpl::eval_if< - is_const - , mpl::identity - , mpl::identity - >::type - type; - - static type - call(Sequence& s) - { - return fusion::begin(s.get_data()); - } - }; + return type(seq,0); + } }; - } -}} + }; +}}} #endif diff --git a/include/boost/fusion/container/set/detail/deref_data_impl.hpp b/include/boost/fusion/container/set/detail/deref_data_impl.hpp new file mode 100644 index 00000000..7238cc6f --- /dev/null +++ b/include/boost/fusion/container/set/detail/deref_data_impl.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + : deref_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/container/set/detail/deref_impl.hpp b/include/boost/fusion/container/set/detail/deref_impl.hpp new file mode 100644 index 00000000..12824e61 --- /dev/null +++ b/include/boost/fusion/container/set/detail/deref_impl.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP + +#include +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_impl; + + template <> + struct deref_impl + { + template + struct apply + { + typedef typename + result_of::at< + typename mpl::if_< + is_const + , typename It::seq_type::storage_type const + , typename It::seq_type::storage_type + >::type + , typename It::index + >::type + type; + + static type + call(It const& it) + { + return at(it.seq->get_data()); + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/set/detail/end_impl.hpp b/include/boost/fusion/container/set/detail/end_impl.hpp index 4df78a3f..a981585b 100644 --- a/include/boost/fusion/container/set/detail/end_impl.hpp +++ b/include/boost/fusion/container/set/detail/end_impl.hpp @@ -1,53 +1,43 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + Copyright (c) 2009 Christopher Schmidt - Distributed under the Boost Software License, Version 1.0. (See accompanying + 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(FUSION_END_IMPL_09162005_1121) -#define FUSION_END_IMPL_09162005_1121 -#include +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP -namespace boost { namespace fusion +#include + +namespace boost { namespace fusion { namespace extension { - struct set_tag; + template + struct end_impl; - namespace extension + template <> + struct end_impl { - template - struct end_impl; - - template <> - struct end_impl + template + struct apply { - template - struct apply + typedef + basic_iterator< + set_iterator_tag + , typename Seq::category + , Seq + , Seq::size::value + > + type; + + static type + call(Seq& seq) { - typedef typename - result_of::end::type - iterator_type; - - typedef typename - result_of::end::type - const_iterator_type; - - typedef typename - mpl::eval_if< - is_const - , mpl::identity - , mpl::identity - >::type - type; - - static type - call(Sequence& s) - { - return fusion::end(s.get_data()); - } - }; + return type(seq,0); + } }; - } -}} + }; +}}} #endif diff --git a/include/boost/fusion/container/set/detail/key_of_impl.hpp b/include/boost/fusion/container/set/detail/key_of_impl.hpp new file mode 100644 index 00000000..9c56aaf5 --- /dev/null +++ b/include/boost/fusion/container/set/detail/key_of_impl.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + : value_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/container/set/detail/lookup_key.hpp b/include/boost/fusion/container/set/detail/lookup_key.hpp deleted file mode 100644 index a1b9e8b9..00000000 --- a/include/boost/fusion/container/set/detail/lookup_key.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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(FUSION_LOOKUP_KEY_09162005_1111) -#define FUSION_LOOKUP_KEY_09162005_1111 - -#include -#include -#include -#include - -namespace boost { namespace fusion -{ - struct void_; -}} - -namespace boost { namespace fusion { namespace detail -{ - template - struct set_data_type - { - typedef typename add_reference::type type; - }; - - template <> - struct set_data_type - { - typedef void_& type; - }; - - template - struct set_const_data_type - { - typedef typename - add_reference< - typename add_const::type - >::type - type; - }; - - template <> - struct set_const_data_type - { - typedef void_ const& type; - }; - - template - struct set_value_type - { - typedef T type; - }; - - template <> - struct set_value_type - { - typedef void_ type; - }; - - template - struct set_key_type - { - typedef T type; - }; - - template - struct set_key_type - { - typedef unknown_key type; - }; - - template - struct set_lookup_key - { - static RT - call(Vector& vec) - { - return vec.at_impl(mpl::int_()); - } - }; - - template - struct set_lookup_key, Vector> - { - static void_& - call(Vector& vec); // intentionally undefined - }; -}}} - -#endif - diff --git a/include/boost/fusion/container/set/detail/set_lookup.hpp b/include/boost/fusion/container/set/detail/set_lookup.hpp deleted file mode 100644 index 6df4b401..00000000 --- a/include/boost/fusion/container/set/detail/set_lookup.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#if !defined(FUSION_SET_LOOKUP_09162005_1116) -#define FUSION_SET_LOOKUP_09162005_1116 - -#include -#include -#include -#include -#include - -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310) -#pragma warning (push) -#pragma warning(disable: 4348) // redefinition of default parameter -#endif - - template - struct meta_at_impl - { - typedef void_ type; - }; - - template - struct meta_find_impl - { - typedef vector_iterator type; - }; - - template - struct meta_find_impl_const - { - typedef vector_iterator type; - }; - - template - vector_iterator - find_impl(mpl::identity) const - { - return vector_iterator(data); - } - - template - vector_iterator - find_impl(mpl::identity) - { - return vector_iterator(data); - } - -#define BOOST_PP_FILENAME_1 \ - -#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_SET_SIZE)) -#include BOOST_PP_ITERATE() - -#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310) -#pragma warning (pop) -#endif - -#endif -#else // defined(BOOST_PP_IS_ITERATING) -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// - -#define N BOOST_PP_ITERATION() - - template - struct meta_at_impl< - typename detail::set_key_type::type, dummy> - { - typedef typename detail::set_value_type::type type; - }; - - typename detail::set_data_type::type - at_impl(mpl::identity::type>) - { - return detail::set_lookup_key< - N - , typename detail::set_data_type::type - , typename detail::set_key_type::type - , storage_type>::call(data); - } - - typename detail::set_const_data_type::type - at_impl(mpl::identity::type>) const - { - return detail::set_lookup_key< - N - , typename detail::set_const_data_type::type - , typename detail::set_key_type::type - , storage_type const>::call(data); - } - - template - struct meta_find_impl< - typename detail::set_key_type::type, dummy> - { - typedef vector_iterator type; - }; - - template - struct meta_find_impl_const< - typename detail::set_key_type::type, dummy> - { - typedef vector_iterator type; - }; - - vector_iterator - find_impl(mpl::identity::type>) - { - return vector_iterator(data); - } - - vector_iterator - find_impl(mpl::identity::type>) const - { - return vector_iterator(data); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - diff --git a/include/boost/fusion/container/set/detail/value_at_key_impl.hpp b/include/boost/fusion/container/set/detail/value_at_key_impl.hpp deleted file mode 100644 index 40f68ba0..00000000 --- a/include/boost/fusion/container/set/detail/value_at_key_impl.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2006 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(FUSION_VALUE_AT_KEY_IMPL_09162005_1123) -#define FUSION_VALUE_AT_KEY_IMPL_09162005_1123 - -#include - -namespace boost { namespace fusion -{ - struct set_tag; - - namespace extension - { - template - struct value_at_key_impl; - - template <> - struct value_at_key_impl - { - template - struct apply - { - typedef typename Sequence:: - template meta_at_impl::type type; - }; - }; - } -}} - -#endif diff --git a/include/boost/fusion/container/set/detail/value_of_data_impl.hpp b/include/boost/fusion/container/set/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..c98e5b9f --- /dev/null +++ b/include/boost/fusion/container/set/detail/value_of_data_impl.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + : value_of_impl + {}; +}}} + +#endif diff --git a/include/boost/fusion/container/set/detail/value_of_impl.hpp b/include/boost/fusion/container/set/detail/value_of_impl.hpp new file mode 100644 index 00000000..02218310 --- /dev/null +++ b/include/boost/fusion/container/set/detail/value_of_impl.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP +#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_impl; + + template <> + struct value_of_impl + { + template + struct apply + { + typedef typename + result_of::value_at< + typename It::seq_type::storage_type + , typename It::index + >::type + type; + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 07580bb6..52c0b5bd 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -11,11 +11,13 @@ #include #include #include -#include #include #include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -23,7 +25,6 @@ namespace boost { namespace fusion { struct void_; - struct set_tag; struct fusion_sequence_tag; template @@ -49,7 +50,6 @@ namespace boost { namespace fusion : data(rhs) {} #include - #include template set& diff --git a/include/boost/fusion/container/set/set_fwd.hpp b/include/boost/fusion/container/set/set_fwd.hpp index 7facb513..082422f1 100644 --- a/include/boost/fusion/container/set/set_fwd.hpp +++ b/include/boost/fusion/container/set/set_fwd.hpp @@ -13,6 +13,8 @@ namespace boost { namespace fusion { struct void_; + struct set_tag; + struct set_iterator_tag; template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( diff --git a/include/boost/fusion/iterator/basic_iterator.hpp b/include/boost/fusion/iterator/basic_iterator.hpp new file mode 100644 index 00000000..80c7f646 --- /dev/null +++ b/include/boost/fusion/iterator/basic_iterator.hpp @@ -0,0 +1,136 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP +#define BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP + +#include + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace extension + { + template + struct value_of_impl; + + template + struct deref_impl; + + template + struct value_of_data_impl; + + template + struct key_of_impl; + + template + struct deref_data_impl; + } + + template + struct basic_iterator + : iterator_facade, Category> + { + typedef mpl::int_ index; + typedef Seq seq_type; + + template + struct value_of + : extension::value_of_impl::template apply + {}; + + template + struct deref + : extension::deref_impl::template apply + {}; + + template + struct value_of_data + : extension::value_of_data_impl::template apply + {}; + + template + struct key_of + : extension::key_of_impl::template apply + {}; + + template + struct deref_data + : extension::deref_data_impl::template apply + {}; + + template + struct advance + { + typedef + basic_iterator + type; + + static type + call(It const& it) + { + return type(*it.seq,0); + } + }; + + template + struct next + : advance > + {}; + + template + struct prior + : advance > + {}; + + template + struct distance + : mpl::minus< + typename It2::index + , typename It1::index + > + {}; + + template + struct equal_to + : mpl::and_< + is_same< + typename remove_const::type + , typename remove_const::type + > + , mpl::equal_to + > + {}; + + template + basic_iterator(basic_iterator const& it) + : seq(it.seq) + {} + + basic_iterator(Seq& seq, int) + : seq(&seq) + {} + + template + basic_iterator& + operator=(basic_iterator const& it) + { + seq=it.seq; + return *this; + } + + Seq* seq; + }; +}} + +#endif diff --git a/include/boost/fusion/iterator/deref_data.hpp b/include/boost/fusion/iterator/deref_data.hpp new file mode 100644 index 00000000..09ba4392 --- /dev/null +++ b/include/boost/fusion/iterator/deref_data.hpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ITERATOR_DEREF_DATA_HPP +#define BOOST_FUSION_ITERATOR_DEREF_DATA_HPP + +#include + +namespace boost { namespace fusion +{ + struct iterator_facade_tag; + + namespace extension + { + template + struct deref_data_impl; + + template <> + struct deref_data_impl + { + template + struct apply + : It::template deref_data + {}; + }; + } + + namespace result_of + { + template + struct deref_data + : extension::deref_data_impl::type>:: + template apply + {}; + } + + template + typename result_of::deref_data::type + deref_data(It const& it) + { + return result_of::deref_data::call(it); + } +}} + +#endif diff --git a/include/boost/fusion/iterator/iterator_facade.hpp b/include/boost/fusion/iterator/iterator_facade.hpp index 3e0a926f..fa74f8dc 100644 --- a/include/boost/fusion/iterator/iterator_facade.hpp +++ b/include/boost/fusion/iterator/iterator_facade.hpp @@ -50,8 +50,7 @@ namespace boost { namespace fusion template struct distance : distance_detail::linear_distance - { - }; + {}; }; }} diff --git a/include/boost/fusion/iterator/key_of.hpp b/include/boost/fusion/iterator/key_of.hpp new file mode 100644 index 00000000..64c2f86a --- /dev/null +++ b/include/boost/fusion/iterator/key_of.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ITERATOR_KEY_OF_HPP +#define BOOST_FUSION_ITERATOR_KEY_OF_HPP + +#include + +namespace boost { namespace fusion +{ + struct iterator_facade_tag; + + namespace extension + { + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + : It::template key_of + {}; + }; + } + + namespace result_of + { + template + struct key_of + : extension::key_of_impl::type>:: + template apply + {}; + } +}} + +#endif diff --git a/include/boost/fusion/iterator/value_of_data.hpp b/include/boost/fusion/iterator/value_of_data.hpp new file mode 100644 index 00000000..4a8316de --- /dev/null +++ b/include/boost/fusion/iterator/value_of_data.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP +#define BOOST_FUSION_ITERATOR_VALUE_OF_DATA_HPP + +#include + +namespace boost { namespace fusion +{ + struct iterator_facade_tag; + + namespace extension + { + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + { + template + struct apply + : It::template value_of_data + {}; + }; + } + + namespace result_of + { + template + struct value_of_data + : extension::value_of_data_impl::type>:: + template apply + {}; + } +}} + +#endif diff --git a/include/boost/fusion/sequence/intrinsic/at_key.hpp b/include/boost/fusion/sequence/intrinsic/at_key.hpp index 849ff294..4c860bc1 100644 --- a/include/boost/fusion/sequence/intrinsic/at_key.hpp +++ b/include/boost/fusion/sequence/intrinsic/at_key.hpp @@ -9,6 +9,8 @@ #define BOOST_FUSION_AT_KEY_20060304_1755 #include +#include +#include #include #include @@ -25,15 +27,28 @@ namespace boost { namespace fusion template struct at_key_impl { - template - struct apply; + template + struct apply + { + typedef typename + result_of::deref_data< + typename result_of::find::type + >::type + type; + + static type + call(Seq& seq) + { + return fusion::deref_data(fusion::find(seq)); + } + }; }; template <> struct at_key_impl { template - struct apply : Sequence::template at_key {}; + struct apply : Sequence::template at_key_impl {}; }; template <> diff --git a/include/boost/fusion/sequence/intrinsic/has_key.hpp b/include/boost/fusion/sequence/intrinsic/has_key.hpp index 4c6a3e07..68582059 100644 --- a/include/boost/fusion/sequence/intrinsic/has_key.hpp +++ b/include/boost/fusion/sequence/intrinsic/has_key.hpp @@ -7,9 +7,11 @@ #if !defined(FUSION_HAS_KEY_09232005_1454) #define FUSION_HAS_KEY_09232005_1454 -#include #include -#include +#include +#include +#include +#include namespace boost { namespace fusion { @@ -26,10 +28,14 @@ namespace boost { namespace fusion template struct has_key_impl { - template + template struct apply - : mpl::not_::type, void_> > + : mpl::not_< + typename result_of::equal_to< + typename result_of::find::type + , typename result_of::end::type + >::type + >::type {}; }; diff --git a/include/boost/fusion/sequence/intrinsic/value_at_key.hpp b/include/boost/fusion/sequence/intrinsic/value_at_key.hpp index dbef3e89..406d7ae2 100644 --- a/include/boost/fusion/sequence/intrinsic/value_at_key.hpp +++ b/include/boost/fusion/sequence/intrinsic/value_at_key.hpp @@ -9,6 +9,8 @@ #define FUSION_VALUE_AT_KEY_05052005_0229 #include +#include +#include #include namespace boost { namespace fusion @@ -24,8 +26,12 @@ namespace boost { namespace fusion template struct value_at_key_impl { - template - struct apply; + template + struct apply + : result_of::value_of_data< + typename result_of::find::type + > + {}; }; template <> diff --git a/include/boost/fusion/view/filter_view/detail/begin_impl.hpp b/include/boost/fusion/view/filter_view/detail/begin_impl.hpp index 2ffe7bd0..7d94261d 100644 --- a/include/boost/fusion/view/filter_view/detail/begin_impl.hpp +++ b/include/boost/fusion/view/filter_view/detail/begin_impl.hpp @@ -11,7 +11,7 @@ namespace boost { namespace fusion { struct filter_view_tag; - template + template struct filter_iterator; namespace extension @@ -28,7 +28,8 @@ namespace boost { namespace fusion typedef typename Sequence::first_type first_type; typedef typename Sequence::last_type last_type; typedef typename Sequence::pred_type pred_type; - typedef filter_iterator type; + typedef typename Sequence::category category; + typedef filter_iterator type; static type call(Sequence& s) diff --git a/include/boost/fusion/view/filter_view/detail/deref_data_impl.hpp b/include/boost/fusion/view/filter_view/detail/deref_data_impl.hpp new file mode 100644 index 00000000..bf721b5a --- /dev/null +++ b/include/boost/fusion/view/filter_view/detail/deref_data_impl.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_DEREF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + { + template + struct apply + { + typedef typename + result_of::deref_data::type + type; + + static type + call(It const& it) + { + return fusion::deref_data(it.first); + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/filter_view/detail/end_impl.hpp b/include/boost/fusion/view/filter_view/detail/end_impl.hpp index 677004d4..baabbd45 100644 --- a/include/boost/fusion/view/filter_view/detail/end_impl.hpp +++ b/include/boost/fusion/view/filter_view/detail/end_impl.hpp @@ -11,7 +11,7 @@ namespace boost { namespace fusion { struct filter_view_tag; - template + template struct filter_iterator; namespace extension @@ -27,7 +27,8 @@ namespace boost { namespace fusion { typedef typename Sequence::last_type last_type; typedef typename Sequence::pred_type pred_type; - typedef filter_iterator type; + typedef typename Sequence::category category; + typedef filter_iterator type; static type call(Sequence& s) diff --git a/include/boost/fusion/view/filter_view/detail/key_of_impl.hpp b/include/boost/fusion/view/filter_view/detail/key_of_impl.hpp new file mode 100644 index 00000000..09d9112b --- /dev/null +++ b/include/boost/fusion/view/filter_view/detail/key_of_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + : result_of::key_of + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/filter_view/detail/next_impl.hpp b/include/boost/fusion/view/filter_view/detail/next_impl.hpp index 8423dfe1..a436bfc2 100644 --- a/include/boost/fusion/view/filter_view/detail/next_impl.hpp +++ b/include/boost/fusion/view/filter_view/detail/next_impl.hpp @@ -8,14 +8,19 @@ #define FUSION_NEXT_IMPL_06052005_0900 #include +#include #include #include +#include +#include +#include +#include namespace boost { namespace fusion { struct filter_view_iterator_tag; - template + template struct filter_iterator; namespace extension @@ -32,6 +37,7 @@ namespace boost { namespace fusion typedef typename Iterator::first_type first_type; typedef typename Iterator::last_type last_type; typedef typename Iterator::pred_type pred_type; + typedef typename Iterator::category category; typedef typename mpl::eval_if< @@ -41,12 +47,19 @@ namespace boost { namespace fusion >::type next_type; - typedef typename detail::static_find_if< - next_type, last_type, pred_type> + typedef typename + detail::static_find_if< + next_type + , last_type + , mpl::bind1< + typename mpl::lambda::type + , mpl::bind1,mpl::_1> + > + > filter; typedef filter_iterator< - typename filter::type, last_type, pred_type> + category, typename filter::type, last_type, pred_type> type; static type diff --git a/include/boost/fusion/view/filter_view/detail/value_of_data_impl.hpp b/include/boost/fusion/view/filter_view/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..38d1bdc0 --- /dev/null +++ b/include/boost/fusion/view/filter_view/detail/value_of_data_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_FILTER_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + { + template + struct apply + : result_of::value_of_data + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/filter_view/filter_view.hpp b/include/boost/fusion/view/filter_view/filter_view.hpp index a34747e6..d913a8c8 100644 --- a/include/boost/fusion/view/filter_view/filter_view.hpp +++ b/include/boost/fusion/view/filter_view/filter_view.hpp @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include + namespace boost { namespace fusion { @@ -29,7 +33,13 @@ namespace boost { namespace fusion { typedef filter_view_tag fusion_tag; typedef fusion_sequence_tag tag; // this gets picked up by MPL - typedef forward_traversal_tag category; + typedef typename + mpl::eval_if< + traits::is_associative + , mpl::inherit2 + , mpl::identity + >::type + category; typedef mpl::true_ is_view; typedef typename result_of::begin::type first_type; diff --git a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp index be93c657..5d1efc87 100644 --- a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp +++ b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp @@ -9,20 +9,29 @@ #include #include +#include #include +#include +#include +#include +#include +#include + #include #include #include #include -#include +#include +#include +#include namespace boost { namespace fusion { struct filter_view_iterator_tag; struct forward_traversal_tag; - template - struct filter_iterator : iterator_base > + template + struct filter_iterator : iterator_base > { typedef convert_iterator first_converter; typedef typename first_converter::type first_iter; @@ -30,8 +39,17 @@ namespace boost { namespace fusion typedef typename last_converter::type last_iter; typedef filter_view_iterator_tag fusion_tag; - typedef forward_traversal_tag category; - typedef detail::static_find_if filter; + typedef Category category; + typedef + detail::static_find_if< + first_iter + , last_iter + , mpl::bind1< + typename mpl::lambda::type + , mpl::bind1,mpl::_1> + > + > + filter; typedef typename filter::type first_type; typedef last_iter last_type; typedef Pred pred_type; diff --git a/include/boost/fusion/view/iterator_range/iterator_range.hpp b/include/boost/fusion/view/iterator_range/iterator_range.hpp index 0036f0ae..14bb2457 100644 --- a/include/boost/fusion/view/iterator_range/iterator_range.hpp +++ b/include/boost/fusion/view/iterator_range/iterator_range.hpp @@ -17,7 +17,6 @@ #include #include #include -#include namespace boost { namespace fusion { diff --git a/include/boost/fusion/view/joint_view/detail/begin_impl.hpp b/include/boost/fusion/view/joint_view/detail/begin_impl.hpp index e2b0281e..140d3756 100644 --- a/include/boost/fusion/view/joint_view/detail/begin_impl.hpp +++ b/include/boost/fusion/view/joint_view/detail/begin_impl.hpp @@ -14,7 +14,7 @@ namespace boost { namespace fusion { struct joint_view_tag; - template + template struct joint_view_iterator; namespace extension @@ -31,13 +31,14 @@ namespace boost { namespace fusion typedef typename Sequence::first_type first_type; typedef typename Sequence::last_type last_type; typedef typename Sequence::concat_type concat_type; + typedef typename Sequence::category category; typedef result_of::equal_to equal_to; typedef typename mpl::if_< equal_to , concat_type - , joint_view_iterator + , joint_view_iterator >::type type; diff --git a/include/boost/fusion/view/joint_view/detail/deref_data_impl.hpp b/include/boost/fusion/view/joint_view/detail/deref_data_impl.hpp new file mode 100644 index 00000000..a60a125f --- /dev/null +++ b/include/boost/fusion/view/joint_view/detail/deref_data_impl.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_DEREF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + { + template + struct apply + { + typedef typename + result_of::deref_data::type + type; + + static type + call(It const& it) + { + return fusion::deref_data(it.first); + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/joint_view/detail/key_of_impl.hpp b/include/boost/fusion/view/joint_view/detail/key_of_impl.hpp new file mode 100644 index 00000000..e413c3d4 --- /dev/null +++ b/include/boost/fusion/view/joint_view/detail/key_of_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + : result_of::key_of + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/joint_view/detail/next_impl.hpp b/include/boost/fusion/view/joint_view/detail/next_impl.hpp index 80d3580d..2313faa0 100644 --- a/include/boost/fusion/view/joint_view/detail/next_impl.hpp +++ b/include/boost/fusion/view/joint_view/detail/next_impl.hpp @@ -15,7 +15,7 @@ namespace boost { namespace fusion { struct joint_view_iterator_tag; - template + template struct joint_view_iterator; namespace extension @@ -32,6 +32,7 @@ namespace boost { namespace fusion typedef typename Iterator::first_type first_type; typedef typename Iterator::last_type last_type; typedef typename Iterator::concat_type concat_type; + typedef typename Iterator::category category; typedef typename result_of::next::type next_type; typedef result_of::equal_to equal_to; @@ -39,7 +40,7 @@ namespace boost { namespace fusion mpl::if_< equal_to , concat_type - , joint_view_iterator + , joint_view_iterator >::type type; diff --git a/include/boost/fusion/view/joint_view/detail/value_of_data_impl.hpp b/include/boost/fusion/view/joint_view/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..cc883d70 --- /dev/null +++ b/include/boost/fusion/view/joint_view/detail/value_of_data_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_JOINT_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + { + template + struct apply + : result_of::value_of_data + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/joint_view/joint_view.hpp b/include/boost/fusion/view/joint_view/joint_view.hpp index 9cc798d3..94404a98 100644 --- a/include/boost/fusion/view/joint_view/joint_view.hpp +++ b/include/boost/fusion/view/joint_view/joint_view.hpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include namespace boost { namespace fusion { @@ -31,7 +34,16 @@ namespace boost { namespace fusion { typedef joint_view_tag fusion_tag; typedef fusion_sequence_tag tag; // this gets picked up by MPL - typedef forward_traversal_tag category; + typedef typename + mpl::eval_if< + mpl::and_< + traits::is_associative + , traits::is_associative + > + , mpl::inherit2 + , mpl::identity + >::type + category; typedef mpl::true_ is_view; typedef typename result_of::begin::type first_type; diff --git a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp index 18696d7e..0fd4c636 100644 --- a/include/boost/fusion/view/joint_view/joint_view_iterator.hpp +++ b/include/boost/fusion/view/joint_view/joint_view_iterator.hpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include namespace boost { namespace fusion @@ -21,9 +24,9 @@ namespace boost { namespace fusion struct joint_view_iterator_tag; struct forward_traversal_tag; - template + template struct joint_view_iterator - : iterator_base > + : iterator_base > { typedef convert_iterator first_converter; typedef convert_iterator last_converter; @@ -34,7 +37,7 @@ namespace boost { namespace fusion typedef typename concat_converter::type concat_type; typedef joint_view_iterator_tag fusion_tag; - typedef forward_traversal_tag category; + typedef Category category; BOOST_STATIC_ASSERT((!result_of::equal_to::value)); joint_view_iterator(First const& first, Concat const& concat) diff --git a/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp b/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp new file mode 100644 index 00000000..2f52bdd8 --- /dev/null +++ b/include/boost/fusion/view/reverse_view/detail/deref_data_impl.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_DEREF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_DEREF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct deref_data_impl; + + template <> + struct deref_data_impl + { + template + struct apply + { + typedef typename + result_of::deref_data::type + type; + + static type + call(It const& it) + { + return fusion::deref_data(it.first); + } + }; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp b/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp new file mode 100644 index 00000000..3d760fd2 --- /dev/null +++ b/include/boost/fusion/view/reverse_view/detail/key_of_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_KEY_OF_IMPL_HPP +#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_KEY_OF_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct key_of_impl; + + template <> + struct key_of_impl + { + template + struct apply + : result_of::key_of + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp b/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp new file mode 100644 index 00000000..69d310ff --- /dev/null +++ b/include/boost/fusion/view/reverse_view/detail/value_of_data_impl.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2009 Christopher Schmidt + + 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) +==============================================================================*/ + +#ifndef BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP +#define BOOST_FUSION_VIEW_REVERSE_VIEW_DETAIL_VALUE_OF_DATA_IMPL_HPP + +#include + +namespace boost { namespace fusion { namespace extension +{ + template + struct value_of_data_impl; + + template <> + struct value_of_data_impl + { + template + struct apply + : result_of::value_of_data + {}; + }; +}}} + +#endif diff --git a/include/boost/fusion/view/reverse_view/reverse_view.hpp b/include/boost/fusion/view/reverse_view/reverse_view.hpp index c939f7ce..08735d45 100644 --- a/include/boost/fusion/view/reverse_view/reverse_view.hpp +++ b/include/boost/fusion/view/reverse_view/reverse_view.hpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include namespace boost { namespace fusion { @@ -32,8 +35,15 @@ namespace boost { namespace fusion typedef reverse_view_tag fusion_tag; typedef fusion_sequence_tag tag; // this gets picked up by MPL typedef mpl::true_ is_view; + typedef typename traits::category_of::type seq_category; - typedef typename traits::category_of::type category; + typedef typename + mpl::eval_if< + traits::is_associative + , mpl::inherit2 + , mpl::identity + >::type + category; typedef typename result_of::begin::type first_type; typedef typename result_of::end::type last_type; typedef typename result_of::size::type size; diff --git a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp index 0a890437..af2267e3 100644 --- a/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp +++ b/include/boost/fusion/view/reverse_view/reverse_view_iterator.hpp @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include #include diff --git a/test/algorithm/erase_key.cpp b/test/algorithm/erase_key.cpp index 56c64780..418b5d77 100644 --- a/test/algorithm/erase_key.cpp +++ b/test/algorithm/erase_key.cpp @@ -66,8 +66,8 @@ main() std::cout << tuple_close(']'); std::cout << tuple_delimiter(", "); - test_set(as_set(erase_key(make_set(1, 'x', 1.5, std::string("hello"))))); - test_map(as_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello")))); + test_set(erase_key(make_set(1, 'x', 1.5, std::string("hello")))); + test_map(erase_key<_2>(make_map<_1, _2, _3, _4>(1, 'x', 1.5, "hello"))); return boost::report_errors(); } diff --git a/test/sequence/as_set.cpp b/test/sequence/as_set.cpp index d13d0959..935da42d 100644 --- a/test/sequence/as_set.cpp +++ b/test/sequence/as_set.cpp @@ -33,7 +33,7 @@ main() std::cout << as_set(make_list(1, 1.23, "harru")) << std::endl; std::cout << as_set(push_back(empty, 999)) << std::endl; - BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru"))) + BOOST_TEST(as_list(as_set(make_list(1, 1.23, "harru"))) == make_list(1, 1.23, std::string("harru"))); BOOST_TEST(as_list(as_set(push_back(empty, 999))) == push_back(empty, 999)); diff --git a/test/sequence/filter_view.cpp b/test/sequence/filter_view.cpp index a89abec2..5c4c1a0c 100644 --- a/test/sequence/filter_view.cpp +++ b/test/sequence/filter_view.cpp @@ -13,6 +13,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -62,22 +68,6 @@ main() std::cout << tuple_close(']'); std::cout << tuple_delimiter(", "); - { // Testing the static find_if (internal function) - - typedef vector vector_type; - - vector_type v(1, 'x', 987654, X()); - typedef vector_iterator begin; - typedef vector_iterator end; - typedef detail::static_find_if > filter; - typedef filter::type type; - - BOOST_TEST(*type(v) == 987654); - std::cout << *type(v) << std::endl; - std::cout << *filter::call(begin(v)) << std::endl; - BOOST_TEST(*type(v) == *filter::call(begin(v))); - } - { typedef vector vector_type; @@ -115,6 +105,23 @@ main() BOOST_MPL_ASSERT((result_of::equal_to::type, result_of::end::type>)); } + { + typedef map, pair > map_type; + map_type m(make_pair(0), make_pair("Bond")); + + typedef filter_view > > filter_view_type; + filter_view_type f(m); + + BOOST_MPL_ASSERT((result_of::has_key::type)); + BOOST_MPL_ASSERT_NOT((result_of::has_key::type)); + + BOOST_MPL_ASSERT((is_same::type>::type, double>)); + BOOST_MPL_ASSERT((is_same::type>::type, std::string>)); + + std::cout << deref_data(begin(f)) << std::endl; + BOOST_TEST((deref_data(begin(f)) == "Bond")); + } + return boost::report_errors(); } diff --git a/test/sequence/iterator_range.cpp b/test/sequence/iterator_range.cpp index af42cadd..d4062840 100644 --- a/test/sequence/iterator_range.cpp +++ b/test/sequence/iterator_range.cpp @@ -5,15 +5,23 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include int @@ -76,6 +84,31 @@ main() BOOST_STATIC_ASSERT(result_of::size::value == 2); } + { + typedef map, pair,pair > map_type; + map_type m(make_pair("foo"), make_pair('x'), make_pair(2)); + + typedef iterator_range< + result_of::begin::type + , result_of::advance_c::type,2>::type + > range_type; + range_type r(begin(m), advance_c<2>(begin(m))); + + BOOST_MPL_ASSERT((result_of::has_key::type)); + BOOST_MPL_ASSERT((result_of::has_key::type)); + + BOOST_MPL_ASSERT((boost::is_same::type>::type, void>)); + BOOST_MPL_ASSERT((boost::is_same::type>::type>::type, double>)); + + BOOST_MPL_ASSERT((boost::is_same::type>::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same::type>::type>::type, char>)); + + std::cout << deref_data(begin(r)) << std::endl; + std::cout << deref_data(next(begin(r))) << std::endl; + BOOST_TEST((deref_data(begin(r)) == "foo")); + BOOST_TEST((deref_data(next(begin(r))) == 'x')); + } + return boost::report_errors(); } diff --git a/test/sequence/joint_view.cpp b/test/sequence/joint_view.cpp index 8dc4eb3c..e53d333c 100644 --- a/test/sequence/joint_view.cpp +++ b/test/sequence/joint_view.cpp @@ -5,13 +5,22 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include +#include +#include #include #include #include #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include struct X { @@ -139,6 +148,40 @@ main() } } + { + typedef map > map_type; + map_type m(make_pair(0)); + + typedef set set_type; + set_type s("foo", 1.3f); + + typedef joint_view joint_view_type; + joint_view_type j(m,s); + + BOOST_MPL_ASSERT((result_of::has_key::type)); + BOOST_MPL_ASSERT((result_of::has_key::type)); + BOOST_MPL_ASSERT((result_of::has_key::type)); + + BOOST_MPL_ASSERT((boost::is_same::type>::type, void>)); + BOOST_MPL_ASSERT((boost::is_same::type>::type>::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same< + result_of::key_of::type>::type>::type>::type + , float>)); + + BOOST_MPL_ASSERT((boost::is_same::type>::type, int>)); + BOOST_MPL_ASSERT((boost::is_same::type>::type>::type, std::string>)); + BOOST_MPL_ASSERT((boost::is_same< + result_of::value_of_data::type>::type>::type>::type + , float>)); + + std::cout << deref_data(begin(j)) << std::endl; + std::cout << deref_data(boost::fusion::next(begin(j))) << std::endl; + std::cout << deref_data(next(boost::fusion::next(begin(j)))) << std::endl; + BOOST_TEST((deref_data(begin(j)) == 0)); + BOOST_TEST((deref_data(boost::fusion::next(begin(j))) == "foo")); + BOOST_TEST((deref_data(next(boost::fusion::next(begin(j)))) == 1.3f)); + } + return boost::report_errors(); } diff --git a/test/sequence/map.cpp b/test/sequence/map.cpp index 5f58b9dc..d4e1cfa3 100644 --- a/test/sequence/map.cpp +++ b/test/sequence/map.cpp @@ -10,7 +10,12 @@ #include #include #include +#include #include +#include +#include +#include +#include #include #include #include @@ -59,6 +64,17 @@ main() BOOST_STATIC_ASSERT((result_of::has_key::value)); BOOST_STATIC_ASSERT((result_of::has_key::value)); BOOST_STATIC_ASSERT((!result_of::has_key::value)); + + std::cout << deref_data(begin(m)) << std::endl; + std::cout << deref_data(next(begin(m))) << std::endl; + + BOOST_TEST(deref_data(begin(m)) == 'X'); + BOOST_TEST(deref_data(next(begin(m))) == "Men"); + + BOOST_STATIC_ASSERT((is_same::type>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type>::type, double>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type, char>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type>::type, std::string>::value)); } { diff --git a/test/sequence/set.cpp b/test/sequence/set.cpp index 95c5b40d..7be0b078 100644 --- a/test/sequence/set.cpp +++ b/test/sequence/set.cpp @@ -10,7 +10,12 @@ #include #include #include +#include #include +#include +#include +#include +#include #include #include #include @@ -48,12 +53,23 @@ main() boost::is_same::type, int>::value)); BOOST_STATIC_ASSERT(( boost::is_same::type, std::string>::value)); - + std::cout << m << std::endl; BOOST_STATIC_ASSERT((result_of::has_key::value)); BOOST_STATIC_ASSERT((result_of::has_key::value)); BOOST_STATIC_ASSERT((!result_of::has_key::value)); + + std::cout << deref_data(begin(m)) << std::endl; + std::cout << deref_data(next(begin(m))) << std::endl; + + BOOST_TEST(deref_data(begin(m)) == 123); + BOOST_TEST(deref_data(next(begin(m))) == "Hola"); + + BOOST_STATIC_ASSERT((is_same::type>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type>::type, std::string>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type>::type>::type, std::string>::value)); } {