|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56536 - in trunk/boost/spirit/home: karma karma/detail karma/directive karma/operator support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-02 18:01:11
Author: hkaiser
Date: 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
New Revision: 56536
URL: http://svn.boost.org/trac/boost/changeset/56536
Log:
Spirit: more clean up of attribute customization points
Text files modified:
trunk/boost/spirit/home/karma/detail/extract_from.hpp | 53 +++++++-----------
trunk/boost/spirit/home/karma/detail/pass_container.hpp | 6 +-
trunk/boost/spirit/home/karma/directive/repeat.hpp | 2
trunk/boost/spirit/home/karma/operator/kleene.hpp | 2
trunk/boost/spirit/home/karma/operator/list.hpp | 2
trunk/boost/spirit/home/karma/operator/plus.hpp | 2
trunk/boost/spirit/home/karma/phoenix_attributes.hpp | 19 +-----
trunk/boost/spirit/home/support/attributes.hpp | 2
trunk/boost/spirit/home/support/attributes_fwd.hpp | 34 ++---------
trunk/boost/spirit/home/support/container.hpp | 113 ++++++++++++++++++++-------------------
10 files changed, 96 insertions(+), 139 deletions(-)
Modified: trunk/boost/spirit/home/karma/detail/extract_from.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/extract_from.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/extract_from.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -25,38 +25,6 @@
// provided also accept spirit's unused_type; all no-ops. Compiler
// optimization will easily strip these away.
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- template <typename Attribute, typename Enable/* = void*/>
- struct extract_from
- {
- typedef Attribute const& type;
- };
-
- template <typename Attribute>
- struct extract_from<optional<Attribute> >
- {
- typedef Attribute const& type;
- };
-
- template <typename Attribute>
- struct extract_from<optional<Attribute const> >
- {
- typedef Attribute const& type;
- };
-
- template <>
- struct extract_from<unused_type>
- {
- typedef unused_type type;
- };
-
- template <>
- struct extract_from<unused_type const>
- {
- typedef unused_type type;
- };
- }
// This is the default case: the plain attribute values
template <typename Attribute, typename Enable/* = void*/>
@@ -102,6 +70,27 @@
};
///////////////////////////////////////////////////////////////////////////
+ namespace result_of
+ {
+ template <typename Attribute>
+ struct extract_from
+ : traits::extract_from_attribute<Attribute>
+ {};
+
+ template <>
+ struct extract_from<unused_type>
+ {
+ typedef unused_type type;
+ };
+
+ template <>
+ struct extract_from<unused_type const>
+ {
+ typedef unused_type type;
+ };
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename Attribute>
typename extract_from_attribute<Attribute>::type
extract_from(Attribute const& attr)
Modified: trunk/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/pass_container.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -75,7 +75,7 @@
bool dispatch_attribute_element(Component const& component, mpl::false_) const
{
// get the next value to generate from container
- typename traits::result_of::iterator<Attr>::type end =
+ typename traits::container_iterator<Attr>::type end =
traits::end(attr);
if (!traits::compare(iter, end) &&
!f(component, traits::deref(iter)))
@@ -94,7 +94,7 @@
template <typename Component>
bool dispatch_attribute_element(Component const& component, mpl::true_) const
{
- typename traits::result_of::iterator<Attr>::type end =
+ typename traits::container_iterator<Attr>::type end =
traits::end(attr);
bool result = f(component, make_iterator_range(iter, end));
if (result)
@@ -168,7 +168,7 @@
F f;
Attr const& attr;
- mutable typename traits::result_of::iterator<Attr>::type iter;
+ mutable typename traits::container_iterator<Attr>::type iter;
};
// Utility function to make a pass_container
Modified: trunk/boost/spirit/home/karma/directive/repeat.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/repeat.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/repeat.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -165,7 +165,7 @@
bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
, Attribute const& attr) const
{
- typedef typename traits::result_of::iterator<
+ typedef typename traits::container_iterator<
typename add_const<Attribute>::type
>::type iterator_type;
Modified: trunk/boost/spirit/home/karma/operator/kleene.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/kleene.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/kleene.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -61,7 +61,7 @@
bool generate(OutputIterator& sink, Context& ctx
, Delimiter const& d, Attribute const& attr) const
{
- typedef typename traits::result_of::iterator<
+ typedef typename traits::container_iterator<
typename add_const<Attribute>::type
>::type iterator_type;
Modified: trunk/boost/spirit/home/karma/operator/list.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/list.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/list.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -84,7 +84,7 @@
bool generate(OutputIterator& sink, Context& ctx
, Delimiter const& d, Attribute const& attr) const
{
- typedef typename traits::result_of::iterator<
+ typedef typename traits::container_iterator<
typename add_const<Attribute>::type
>::type iterator_type;
Modified: trunk/boost/spirit/home/karma/operator/plus.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/plus.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/plus.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -61,7 +61,7 @@
bool generate(OutputIterator& sink, Context& ctx
, Delimiter const& d, Attribute const& attr) const
{
- typedef typename traits::result_of::iterator<
+ typedef typename traits::container_iterator<
typename add_const<Attribute>::type
>::type iterator_type;
Modified: trunk/boost/spirit/home/karma/phoenix_attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/phoenix_attributes.hpp (original)
+++ trunk/boost/spirit/home/karma/phoenix_attributes.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -24,14 +24,11 @@
// generator functions in the context of generators expecting a container
// attribute (Kleene, plus, list, repeat, etc.)
///////////////////////////////////////////////////////////////////////////
- namespace result_of
+ template <typename Eval>
+ struct container_iterator<phoenix::actor<Eval> const>
{
- template <typename Eval>
- struct iterator<phoenix::actor<Eval> const>
- {
- typedef phoenix::actor<Eval> const& type;
- };
- }
+ typedef phoenix::actor<Eval> const& type;
+ };
template <typename Eval>
struct begin_container<phoenix::actor<Eval> const>
@@ -87,14 +84,6 @@
// Handle Phoenix actors as attributes, just invoke the function object
// and deal with the result as the attribute.
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- template <typename Eval>
- struct extract_from<phoenix::actor<Eval> >
- : boost::result_of<phoenix::actor<Eval>()>
- {};
- }
-
template <typename Eval>
struct extract_from_attribute<phoenix::actor<Eval> >
{
Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -384,7 +384,7 @@
namespace result_of
{
- template <typename Exposed, typename Transformed, typename Enable/* = void*/>
+ template <typename Exposed, typename Transformed>
struct pre_transform
: traits::transform_attribute<Exposed, Transformed>
{};
Modified: trunk/boost/spirit/home/support/attributes_fwd.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes_fwd.hpp (original)
+++ trunk/boost/spirit/home/support/attributes_fwd.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -34,15 +34,6 @@
// the user is able specify specific transformation rules for any attribute
// type.
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- ///////////////////////////////////////////////////////////////////////
- // Attribute type to be returned by pre_transform()
- ///////////////////////////////////////////////////////////////////////
- template <typename T, typename Attribute, typename Enable = void>
- struct pre_transform;
- }
-
template <typename Exposed, typename Transformed, typename Enable = void>
struct transform_attribute;
@@ -54,15 +45,6 @@
struct assign_to_attribute_from_value;
///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- ///////////////////////////////////////////////////////////////////////
- // Attribute type to be extracted by extract_from()
- ///////////////////////////////////////////////////////////////////////
- template <typename Attribute, typename Enable = void>
- struct extract_from;
- }
-
template <typename Attribute, typename Enable = void>
struct extract_from_attribute;
@@ -78,6 +60,9 @@
template <typename Container, typename Enable = void>
struct container_value;
+ template <typename Container, typename Enable = void>
+ struct container_iterator;
+
template <typename T, typename Enable = void>
struct is_container;
@@ -85,16 +70,9 @@
template <typename Container, typename T, typename Enable = void>
struct push_back_container;
- ///////////////////////////////////////////////////////////////////////////
- namespace result_of
- {
- ///////////////////////////////////////////////////////////////////////
- // Determine the iterator type of the given container type
- ///////////////////////////////////////////////////////////////////////
- template <typename Container, typename Enable = void>
- struct iterator;
- }
-
+ ///////////////////////////////////////////////////////////////////////
+ // Determine the iterator type of the given container type
+ ///////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable = void>
struct begin_container;
Modified: trunk/boost/spirit/home/support/container.hpp
==============================================================================
--- trunk/boost/spirit/home/support/container.hpp (original)
+++ trunk/boost/spirit/home/support/container.hpp 2009-10-02 18:01:09 EDT (Fri, 02 Oct 2009)
@@ -65,57 +65,9 @@
#undef BOOST_SPIRIT_IS_CONTAINER
- ///////////////////////////////////////////////////////////////////////////
- namespace detail
- {
- template <typename T>
- struct remove_value_const
- {
- typedef T type;
- };
-
- template <typename T>
- struct remove_value_const<T const>
- : remove_value_const<T>
- {};
-
- template <typename F, typename S>
- struct remove_value_const<std::pair<F, S> >
- {
- typedef typename remove_value_const<F>::type first_type;
- typedef typename remove_value_const<S>::type second_type;
- typedef std::pair<first_type, second_type> type;
- };
- }
-
namespace result_of
{
///////////////////////////////////////////////////////////////////////
- template <typename Container, typename Enable/* = void*/>
- struct iterator
- {
- typedef typename Container::iterator type;
- };
-
- template <typename Container>
- struct iterator<Container const>
- {
- typedef typename Container::const_iterator type;
- };
-
- template <>
- struct iterator<unused_type>
- {
- typedef unused_type const* type;
- };
-
- template <>
- struct iterator<unused_type const>
- {
- typedef unused_type const* type;
- };
-
- ///////////////////////////////////////////////////////////////////////
template <typename T>
struct optional_value
{
@@ -147,6 +99,29 @@
};
}
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T>
+ struct remove_value_const
+ {
+ typedef T type;
+ };
+
+ template <typename T>
+ struct remove_value_const<T const>
+ : remove_value_const<T>
+ {};
+
+ template <typename F, typename S>
+ struct remove_value_const<std::pair<F, S> >
+ {
+ typedef typename remove_value_const<F>::type first_type;
+ typedef typename remove_value_const<S>::type second_type;
+ typedef std::pair<first_type, second_type> type;
+ };
+ }
+
///////////////////////////////////////////////////////////////////////
template <typename Container, typename Enable/* = void*/>
struct container_value
@@ -191,6 +166,31 @@
};
///////////////////////////////////////////////////////////////////////////
+ template <typename Container, typename Enable/* = void*/>
+ struct container_iterator
+ {
+ typedef typename Container::iterator type;
+ };
+
+ template <typename Container>
+ struct container_iterator<Container const>
+ {
+ typedef typename Container::const_iterator type;
+ };
+
+ template <>
+ struct container_iterator<unused_type>
+ {
+ typedef unused_type const* type;
+ };
+
+ template <>
+ struct container_iterator<unused_type const>
+ {
+ typedef unused_type const* type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename T, typename Enable/* = void*/>
struct optional_attribute
{
@@ -349,7 +349,7 @@
template <typename Container, typename Enable/* = void*/>
struct begin_container
{
- typedef typename result_of::iterator<Container>::type type;
+ typedef typename container_iterator<Container>::type type;
static type call(Container& c)
{
return c.begin();
@@ -360,7 +360,7 @@
{
template <typename Container>
struct begin
- : traits::begin_container<Container>
+ : traits::container_iterator<Container>
{};
}
@@ -381,7 +381,7 @@
template <typename Container, typename Enable/* = void*/>
struct end_container
{
- typedef typename result_of::iterator<Container>::type type;
+ typedef typename container_iterator<Container>::type type;
static type call(Container& c)
{
return c.end();
@@ -392,7 +392,7 @@
{
template <typename Container>
struct end
- : traits::end_container<Container>
+ : traits::container_iterator<Container>
{};
}
@@ -456,8 +456,9 @@
{
template <typename Iterator>
struct next
- : traits::next_iterator<Iterator>
- {};
+ {
+ typedef Iterator type;
+ };
}
template <typename Iterator>
@@ -467,10 +468,10 @@
return next_iterator<Iterator>::call(it);
}
- inline unused_type
+ inline unused_type const*
next(unused_type const*)
{
- return unused;
+ return &unused;
}
///////////////////////////////////////////////////////////////////////////
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk