diff --git a/example/extension/detail/advance_impl.hpp b/example/extension/detail/advance_impl.hpp index 6663c88e..91309672 100644 --- a/example/extension/detail/advance_impl.hpp +++ b/example/extension/detail/advance_impl.hpp @@ -9,12 +9,15 @@ #if !defined(BOOST_FUSION_ADVANCE_IMPL_20060222_2150) #define BOOST_FUSION_ADVANCE_IMPL_20060222_2150 -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; template struct example_struct_iterator; +} + +namespace boost { namespace fusion { namespace extension { @@ -22,14 +25,14 @@ namespace boost { namespace fusion { struct advance_impl; template<> - struct advance_impl + struct advance_impl { template struct apply { typedef typename Iterator::struct_type struct_type; typedef typename Iterator::index index; - typedef example_struct_iterator< + typedef example::example_struct_iterator< struct_type, index::value + N::value> type; static type diff --git a/example/extension/detail/at_impl.hpp b/example/extension/detail/at_impl.hpp index 1fca18d9..058c31cc 100644 --- a/example/extension/detail/at_impl.hpp +++ b/example/extension/detail/at_impl.hpp @@ -14,9 +14,12 @@ #include #include -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -24,7 +27,7 @@ namespace boost { namespace fusion { struct at_impl; template<> - struct at_impl + struct at_impl { template struct apply; diff --git a/example/extension/detail/at_key_impl.hpp b/example/extension/detail/at_key_impl.hpp index 33761815..39d914dc 100644 --- a/example/extension/detail/at_key_impl.hpp +++ b/example/extension/detail/at_key_impl.hpp @@ -19,9 +19,12 @@ namespace fields struct age; } -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -29,7 +32,7 @@ namespace boost { namespace fusion { struct at_key_impl; template<> - struct at_key_impl + struct at_key_impl { template struct apply; diff --git a/example/extension/detail/begin_impl.hpp b/example/extension/detail/begin_impl.hpp index e24ef48b..d0c1dafc 100644 --- a/example/extension/detail/begin_impl.hpp +++ b/example/extension/detail/begin_impl.hpp @@ -11,22 +11,25 @@ #include "../example_struct_iterator.hpp" +namespace example +{ + struct example_sequence_tag; +} + namespace boost { namespace fusion { - struct example_sequence_tag; - namespace extension { template struct begin_impl; template<> - struct begin_impl + struct begin_impl { template struct apply { - typedef example_struct_iterator type; + typedef example::example_struct_iterator type; static type call(Sequence& seq) diff --git a/example/extension/detail/category_of_impl.hpp b/example/extension/detail/category_of_impl.hpp index f3fbf63e..56fdd082 100644 --- a/example/extension/detail/category_of_impl.hpp +++ b/example/extension/detail/category_of_impl.hpp @@ -9,22 +9,24 @@ #if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037) #define BOOST_FUSION_CATEGORY_OF_IMPL_20060223_2037 -namespace boost { namespace fusion { +#include - struct random_access_traversal_tag; +namespace example +{ + struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { - template - struct category_of_impl; - template<> - struct category_of_impl + struct category_of_impl { template struct apply { - typedef random_access_traversal_tag type; + struct type : random_access_traversal_tag, associative_sequence_tag {}; }; }; } diff --git a/example/extension/detail/deref_impl.hpp b/example/extension/detail/deref_impl.hpp index 2be589d6..7454c44c 100644 --- a/example/extension/detail/deref_impl.hpp +++ b/example/extension/detail/deref_impl.hpp @@ -15,12 +15,15 @@ #include -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; template struct example_struct_iterator; +} + +namespace boost { namespace fusion { namespace extension { @@ -28,32 +31,32 @@ namespace boost { namespace fusion { struct deref_impl; template<> - struct deref_impl + struct deref_impl { template struct apply; template - struct apply > + struct apply > { typedef typename mpl::if_< is_const, std::string const&, std::string&>::type type; static type - call(example_struct_iterator const& it) + call(example::example_struct_iterator const& it) { return it.struct_.name; } }; template - struct apply > + struct apply > { typedef typename mpl::if_< is_const, int const&, int&>::type type; static type - call(example_struct_iterator const& it) + call(example::example_struct_iterator const& it) { return it.struct_.age; } diff --git a/example/extension/detail/distance_impl.hpp b/example/extension/detail/distance_impl.hpp index d576cdb7..3b93d1e0 100644 --- a/example/extension/detail/distance_impl.hpp +++ b/example/extension/detail/distance_impl.hpp @@ -11,9 +11,12 @@ #include -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -21,7 +24,7 @@ namespace boost { namespace fusion { struct distance_impl; template<> - struct distance_impl + struct distance_impl { template struct apply diff --git a/example/extension/detail/end_impl.hpp b/example/extension/detail/end_impl.hpp index 197ed5b7..5ab0608b 100644 --- a/example/extension/detail/end_impl.hpp +++ b/example/extension/detail/end_impl.hpp @@ -11,22 +11,25 @@ #include "../example_struct_iterator.hpp" +namespace example +{ + struct example_sequence_tag; +} + namespace boost { namespace fusion { - struct example_sequence_tag; - namespace extension { template struct end_impl; template<> - struct end_impl + struct end_impl { template struct apply { - typedef example_struct_iterator type; + typedef example::example_struct_iterator type; static type call(Sequence& seq) diff --git a/example/extension/detail/equal_to_impl.hpp b/example/extension/detail/equal_to_impl.hpp index 6ab5841f..fb261071 100644 --- a/example/extension/detail/equal_to_impl.hpp +++ b/example/extension/detail/equal_to_impl.hpp @@ -11,9 +11,12 @@ #include -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -21,7 +24,7 @@ namespace boost { namespace fusion { struct equal_to_impl; template<> - struct equal_to_impl + struct equal_to_impl { template struct apply diff --git a/example/extension/detail/has_key_impl.hpp b/example/extension/detail/has_key_impl.hpp index 45cd554c..47a39fda 100644 --- a/example/extension/detail/has_key_impl.hpp +++ b/example/extension/detail/has_key_impl.hpp @@ -18,9 +18,12 @@ namespace fields struct age; } -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -28,7 +31,7 @@ namespace boost { namespace fusion { struct has_key_impl; template<> - struct has_key_impl + struct has_key_impl { template struct apply diff --git a/example/extension/detail/is_associative_impl.hpp b/example/extension/detail/is_associative_impl.hpp deleted file mode 100644 index 18fc9922..00000000 --- a/example/extension/detail/is_associative_impl.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2006 Dan Marsden - - 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) -==============================================================================*/ -#if !defined(BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324) -#define BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2324 - -#include - -namespace boost { namespace fusion { - - struct example_sequence_tag; - - namespace extension - { - template - struct is_associative_impl; - - template<> - struct is_associative_impl - { - template - struct apply - : mpl::true_ - {}; - }; - } -}} - -#endif diff --git a/example/extension/detail/is_sequence_impl.hpp b/example/extension/detail/is_sequence_impl.hpp index b8c9bede..06a7d433 100644 --- a/example/extension/detail/is_sequence_impl.hpp +++ b/example/extension/detail/is_sequence_impl.hpp @@ -11,17 +11,20 @@ #include -namespace boost { namespace fusion +namespace example { struct example_sequence_tag; +} +namespace boost { namespace fusion +{ namespace extension { template struct is_sequence_impl; template<> - struct is_sequence_impl + struct is_sequence_impl { template struct apply : mpl::true_ {}; diff --git a/example/extension/detail/is_view_impl.hpp b/example/extension/detail/is_view_impl.hpp index 957051d5..02151d52 100644 --- a/example/extension/detail/is_view_impl.hpp +++ b/example/extension/detail/is_view_impl.hpp @@ -11,17 +11,20 @@ #include -namespace boost { namespace fusion +namespace example { struct example_sequence_tag; +} +namespace boost { namespace fusion +{ namespace extension { template struct is_view_impl; template<> - struct is_view_impl + struct is_view_impl : boost::mpl::false_ {}; } diff --git a/example/extension/detail/next_impl.hpp b/example/extension/detail/next_impl.hpp index c83f414d..763a7ccc 100644 --- a/example/extension/detail/next_impl.hpp +++ b/example/extension/detail/next_impl.hpp @@ -9,12 +9,15 @@ #if !defined(BOOST_FUSION_NEXT_IMPL_20060222_1859) #define BOOST_FUSION_NEXT_IMPL_20060222_1859 -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; template struct example_struct_iterator; +} + +namespace boost { namespace fusion { namespace extension { @@ -22,14 +25,14 @@ namespace boost { namespace fusion { struct next_impl; template<> - struct next_impl + struct next_impl { template struct apply { typedef typename Iterator::struct_type struct_type; typedef typename Iterator::index index; - typedef example_struct_iterator type; + typedef example::example_struct_iterator type; static type call(Iterator const& i) diff --git a/example/extension/detail/prior_impl.hpp b/example/extension/detail/prior_impl.hpp index 5f8a7d22..990fbbc7 100644 --- a/example/extension/detail/prior_impl.hpp +++ b/example/extension/detail/prior_impl.hpp @@ -9,12 +9,15 @@ #if !defined(BOOST_FUSION_PRIOR_IMPL_20060222_1944) #define BOOST_FUSION_PRIOR_IMPL_20060222_1944 -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; template struct example_struct_iterator; +} + +namespace boost { namespace fusion { namespace extension { @@ -22,14 +25,14 @@ namespace boost { namespace fusion { struct prior_impl; template<> - struct prior_impl + struct prior_impl { template struct apply { typedef typename Iterator::struct_type struct_type; typedef typename Iterator::index index; - typedef example_struct_iterator type; + typedef example::example_struct_iterator type; static type call(Iterator const& i) diff --git a/example/extension/detail/size_impl.hpp b/example/extension/detail/size_impl.hpp index 4e62331f..a9c081c3 100644 --- a/example/extension/detail/size_impl.hpp +++ b/example/extension/detail/size_impl.hpp @@ -11,9 +11,12 @@ #include -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -21,7 +24,7 @@ namespace boost { namespace fusion { struct size_impl; template<> - struct size_impl + struct size_impl { template struct apply diff --git a/example/extension/detail/value_at_impl.hpp b/example/extension/detail/value_at_impl.hpp index 9685e88c..38fc6ab3 100644 --- a/example/extension/detail/value_at_impl.hpp +++ b/example/extension/detail/value_at_impl.hpp @@ -9,9 +9,12 @@ #if !defined(BOOST_FUSION_VALUE_AT_IMPL_20060223_2025) #define BOOST_FUSION_VALUE_AT_IMPL_20060223_2025 -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -19,7 +22,7 @@ namespace boost { namespace fusion { struct value_at_impl; template<> - struct value_at_impl + struct value_at_impl { template struct apply; diff --git a/example/extension/detail/value_at_key_impl.hpp b/example/extension/detail/value_at_key_impl.hpp index 52b246bb..bb0c68e9 100644 --- a/example/extension/detail/value_at_key_impl.hpp +++ b/example/extension/detail/value_at_key_impl.hpp @@ -15,9 +15,12 @@ namespace fields struct age; } -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace extension { @@ -25,7 +28,7 @@ namespace boost { namespace fusion { struct value_at_key_impl; template<> - struct value_at_key_impl + struct value_at_key_impl { template struct apply; diff --git a/example/extension/detail/value_of_impl.hpp b/example/extension/detail/value_of_impl.hpp index 2d2d33c5..b4a09742 100644 --- a/example/extension/detail/value_of_impl.hpp +++ b/example/extension/detail/value_of_impl.hpp @@ -11,12 +11,15 @@ #include -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; template struct example_struct_iterator; +} + +namespace boost { namespace fusion { namespace extension { @@ -24,23 +27,22 @@ namespace boost { namespace fusion { struct value_of_impl; template<> - struct value_of_impl + struct value_of_impl { template struct apply; template - struct apply > + struct apply > { typedef std::string type; }; template - struct apply > + struct apply > { typedef int type; }; - }; } }} diff --git a/example/extension/example_struct.hpp b/example/extension/example_struct.hpp index 9e742ae3..d07aeb78 100644 --- a/example/extension/example_struct.hpp +++ b/example/extension/example_struct.hpp @@ -21,7 +21,6 @@ #include "./detail/value_at_key_impl.hpp" #include "./detail/has_key_impl.hpp" #include "./detail/is_sequence_impl.hpp" -#include "./detail/is_associative_impl.hpp" #include "./detail/is_view_impl.hpp" #endif diff --git a/example/extension/example_struct_iterator.hpp b/example/extension/example_struct_iterator.hpp index 04425acc..c3165d8e 100644 --- a/example/extension/example_struct_iterator.hpp +++ b/example/extension/example_struct_iterator.hpp @@ -10,6 +10,7 @@ #define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR #include +#include #include #include #include @@ -22,26 +23,43 @@ #include "./detail/value_of_impl.hpp" #include "./detail/equal_to_impl.hpp" -namespace boost { namespace fusion { - +namespace example +{ struct example_struct_iterator_tag; - struct random_access_traversal_tag; + template + struct example_struct_iterator; +} + +namespace boost { namespace fusion { + + struct random_access_traversal_tag; + + namespace traits + { + template + struct tag_of > + { + typedef example::example_struct_iterator_tag type; + }; + } +}} + +namespace example { template struct example_struct_iterator - : iterator_base > + : boost::fusion::iterator_base > { BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3); typedef Struct struct_type; - typedef mpl::int_ index; - typedef example_struct_iterator_tag fusion_tag; - typedef random_access_traversal_tag category; + typedef boost::mpl::int_ index; + typedef boost::fusion::random_access_traversal_tag category; example_struct_iterator(Struct& str) : struct_(str) {} Struct& struct_; }; -}} +} #endif diff --git a/example/extension/tag_of.hpp b/example/extension/tag_of.hpp index dfe06dfc..4eb3e936 100644 --- a/example/extension/tag_of.hpp +++ b/example/extension/tag_of.hpp @@ -12,16 +12,19 @@ #include #include "./example_struct_type.hpp" -namespace boost { namespace fusion { - +namespace example +{ struct example_sequence_tag; +} + +namespace boost { namespace fusion { namespace traits { template<> struct tag_of { - typedef example_sequence_tag type; + typedef example::example_sequence_tag type; }; }}} diff --git a/example/extension/test_example.cpp b/example/extension/test_example.cpp index 8a858c0b..dc16a462 100644 --- a/example/extension/test_example.cpp +++ b/example/extension/test_example.cpp @@ -12,8 +12,8 @@ #include #include +#include #include -#include #include #include @@ -21,8 +21,12 @@ int main() { example::example_struct bert("bert", 99); using namespace boost::fusion; + BOOST_MPL_ASSERT((traits::is_associative)); - BOOST_TEST(*begin(bert) == "bert"); + BOOST_MPL_ASSERT((traits::is_random_access)); + BOOST_MPL_ASSERT((traits::is_sequence)); + + BOOST_TEST(deref(begin(bert)) == "bert"); BOOST_TEST(*next(begin(bert)) == 99); BOOST_TEST(*prior(end(bert)) == 99); BOOST_TEST(*advance_c<1>(begin(bert)) == 99); @@ -55,9 +59,5 @@ int main() BOOST_TEST(size(bert) == 2); - BOOST_MPL_ASSERT((boost::is_same::type, random_access_traversal_tag>)); - - BOOST_MPL_ASSERT((traits::is_sequence)); - return boost::report_errors(); }