better namespace discipline, ftag removal

[SVN r35435]
This commit is contained in:
Dan Marsden
2006-10-01 15:47:17 +00:00
parent 3f27fbe969
commit dbb2975df8
23 changed files with 158 additions and 120 deletions

View File

@ -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<typename Struct, int Pos>
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<example_struct_iterator_tag>
struct advance_impl<example::example_struct_iterator_tag>
{
template<typename Iterator, typename N>
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

View File

@ -14,9 +14,12 @@
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_const.hpp>
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<example_sequence_tag>
struct at_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply;

View File

@ -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<example_sequence_tag>
struct at_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply;

View File

@ -11,9 +11,12 @@
#include "../example_struct_iterator.hpp"
namespace boost { namespace fusion {
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
@ -21,12 +24,12 @@ namespace boost { namespace fusion {
struct begin_impl;
template<>
struct begin_impl<example_sequence_tag>
struct begin_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef example_struct_iterator<Sequence, 0> type;
typedef example::example_struct_iterator<Sequence, 0> type;
static type
call(Sequence& seq)

View File

@ -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 <boost/fusion/support/category_of.hpp>
struct random_access_traversal_tag;
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct category_of_impl;
template<>
struct category_of_impl<example_sequence_tag>
struct category_of_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef random_access_traversal_tag type;
struct type : random_access_traversal_tag, associative_sequence_tag {};
};
};
}

View File

@ -15,12 +15,15 @@
#include <string>
namespace boost { namespace fusion {
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
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<example_struct_iterator_tag>
struct deref_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example_struct_iterator<Struct, 0> >
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef typename mpl::if_<
is_const<Struct>, std::string const&, std::string&>::type type;
static type
call(example_struct_iterator<Struct, 0> const& it)
call(example::example_struct_iterator<Struct, 0> const& it)
{
return it.struct_.name;
}
};
template<typename Struct>
struct apply<example_struct_iterator<Struct, 1> >
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef typename mpl::if_<
is_const<Struct>, int const&, int&>::type type;
static type
call(example_struct_iterator<Struct, 1> const& it)
call(example::example_struct_iterator<Struct, 1> const& it)
{
return it.struct_.age;
}

View File

@ -11,9 +11,12 @@
#include <boost/mpl/minus.hpp>
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<example_struct_iterator_tag>
struct distance_impl<example::example_struct_iterator_tag>
{
template<typename First, typename Last>
struct apply

View File

@ -11,9 +11,12 @@
#include "../example_struct_iterator.hpp"
namespace boost { namespace fusion {
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion {
namespace extension
{
@ -21,12 +24,12 @@ namespace boost { namespace fusion {
struct end_impl;
template<>
struct end_impl<example_sequence_tag>
struct end_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply
{
typedef example_struct_iterator<Sequence, 2> type;
typedef example::example_struct_iterator<Sequence, 2> type;
static type
call(Sequence& seq)

View File

@ -11,9 +11,12 @@
#include <boost/mpl/equal_to.hpp>
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<example_struct_iterator_tag>
struct equal_to_impl<example::example_struct_iterator_tag>
{
template<typename It1, typename It2>
struct apply

View File

@ -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<example_sequence_tag>
struct has_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename Key>
struct apply

View File

@ -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 <boost/mpl/bool.hpp>
namespace boost { namespace fusion {
struct example_sequence_tag;
namespace extension
{
template<typename Tag>
struct is_associative_impl;
template<>
struct is_associative_impl<example_sequence_tag>
{
template<typename Seq>
struct apply
: mpl::true_
{};
};
}
}}
#endif

View File

@ -11,17 +11,20 @@
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion
{
namespace extension
{
template<typename Tag>
struct is_sequence_impl;
template<>
struct is_sequence_impl<example_sequence_tag>
struct is_sequence_impl<example::example_sequence_tag>
{
template<typename T>
struct apply : mpl::true_ {};

View File

@ -11,17 +11,20 @@
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
namespace example
{
struct example_sequence_tag;
}
namespace boost { namespace fusion
{
namespace extension
{
template<typename Tag>
struct is_view_impl;
template<>
struct is_view_impl<example_sequence_tag>
struct is_view_impl<example::example_sequence_tag>
: boost::mpl::false_
{};
}

View File

@ -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<typename Struct, int Pos>
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<example_struct_iterator_tag>
struct next_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example_struct_iterator<struct_type, index::value + 1> type;
typedef example::example_struct_iterator<struct_type, index::value + 1> type;
static type
call(Iterator const& i)

View File

@ -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<typename Struct, int Pos>
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<example_struct_iterator_tag>
struct prior_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply
{
typedef typename Iterator::struct_type struct_type;
typedef typename Iterator::index index;
typedef example_struct_iterator<struct_type, index::value - 1> type;
typedef example::example_struct_iterator<struct_type, index::value - 1> type;
static type
call(Iterator const& i)

View File

@ -11,9 +11,12 @@
#include <boost/mpl/int.hpp>
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<example_sequence_tag>
struct size_impl<example::example_sequence_tag>
{
template<typename Sequence>
struct apply

View File

@ -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<example_sequence_tag>
struct value_at_impl<example::example_sequence_tag>
{
template<typename Sequence, typename N>
struct apply;

View File

@ -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<example_sequence_tag>
struct value_at_key_impl<example::example_sequence_tag>
{
template<typename Sequence, typename N>
struct apply;

View File

@ -11,12 +11,15 @@
#include <string>
namespace boost { namespace fusion {
namespace example
{
struct example_struct_iterator_tag;
template<typename Struct, int Pos>
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<example_struct_iterator_tag>
struct value_of_impl<example::example_struct_iterator_tag>
{
template<typename Iterator>
struct apply;
template<typename Struct>
struct apply<example_struct_iterator<Struct, 0> >
struct apply<example::example_struct_iterator<Struct, 0> >
{
typedef std::string type;
};
template<typename Struct>
struct apply<example_struct_iterator<Struct, 1> >
struct apply<example::example_struct_iterator<Struct, 1> >
{
typedef int type;
};
};
}
}}

View File

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

View File

@ -10,6 +10,7 @@
#define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/static_assert.hpp>
@ -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<typename Struct, int Pos>
struct example_struct_iterator;
}
namespace boost { namespace fusion {
struct random_access_traversal_tag;
namespace traits
{
template<typename Struct, int Pos>
struct tag_of<example::example_struct_iterator<Struct, Pos> >
{
typedef example::example_struct_iterator_tag type;
};
}
}}
namespace example {
template<typename Struct, int Pos>
struct example_struct_iterator
: iterator_base<example_struct_iterator<Struct, Pos> >
: boost::fusion::iterator_base<example_struct_iterator<Struct, Pos> >
{
BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
typedef Struct struct_type;
typedef mpl::int_<Pos> index;
typedef example_struct_iterator_tag fusion_tag;
typedef random_access_traversal_tag category;
typedef boost::mpl::int_<Pos> index;
typedef boost::fusion::random_access_traversal_tag category;
example_struct_iterator(Struct& str)
: struct_(str) {}
Struct& struct_;
};
}}
}
#endif

View File

@ -12,16 +12,19 @@
#include <boost/fusion/support/tag_of_fwd.hpp>
#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<example::example_struct>
{
typedef example_sequence_tag type;
typedef example::example_sequence_tag type;
};
}}}

View File

@ -12,8 +12,8 @@
#include <boost/fusion/sequence/intrinsic.hpp>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/support/is_associative.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/assert.hpp>
@ -21,8 +21,12 @@ int main()
{
example::example_struct bert("bert", 99);
using namespace boost::fusion;
BOOST_MPL_ASSERT((traits::is_associative<example::example_struct>));
BOOST_TEST(*begin(bert) == "bert");
BOOST_MPL_ASSERT((traits::is_random_access<example::example_struct>));
BOOST_MPL_ASSERT((traits::is_sequence<example::example_struct>));
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<traits::category_of<example::example_struct>::type, random_access_traversal_tag>));
BOOST_MPL_ASSERT((traits::is_sequence<example::example_struct>));
return boost::report_errors();
}