Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56742 - in trunk/boost/spirit/home: qi/nonterminal support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-12 12:33:34


Author: hkaiser
Date: 2009-10-12 12:33:33 EDT (Mon, 12 Oct 2009)
New Revision: 56742
URL: http://svn.boost.org/trac/boost/changeset/56742

Log:
Spirit: added missing specialization to transform_attribute.
Text files modified:
   trunk/boost/spirit/home/qi/nonterminal/rule.hpp | 8 ++++----
   trunk/boost/spirit/home/support/attributes.hpp | 10 +++++++++-
   2 files changed, 13 insertions(+), 5 deletions(-)

Modified: trunk/boost/spirit/home/qi/nonterminal/rule.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal/rule.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal/rule.hpp 2009-10-12 12:33:33 EDT (Mon, 12 Oct 2009)
@@ -221,8 +221,8 @@
                 typedef traits::transform_attribute<
                     typename make_attribute::type, attr_type> transform;
 
- typename transform::type attr_ =
- transform::pre(make_attribute::call(attr));
+ typename make_attribute::type made_attr = make_attribute::call(attr);
+ typename transform::type attr_ = transform::pre(made_attr);
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
@@ -261,8 +261,8 @@
                 typedef traits::transform_attribute<
                     typename make_attribute::type, attr_type> transform;
 
- typename transform::type attr_ =
- transform::pre(make_attribute::call(attr));
+ typename make_attribute::type made_attr = make_attribute::call(attr);
+ typename transform::type attr_ = transform::pre(made_attr);
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited

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-12 12:33:33 EDT (Mon, 12 Oct 2009)
@@ -325,7 +325,6 @@
         typedef Transformed type;
 
         static Transformed pre(Exposed& val) { return Transformed(val); }
- static Transformed pre(Exposed const& val) { return Transformed(val); }
 
         // By default do post transformation only if types are convertible,
         // otherwise we assume no post transform is required (i.e. the user
@@ -352,6 +351,15 @@
         // Karma only, no post() required
     };
 
+ // handle case where no transformation is required as the types are the same
+ template <typename Attribute>
+ struct transform_attribute<Attribute, Attribute>
+ {
+ typedef Attribute& type;
+ static Attribute& pre(Attribute& val) { return val; }
+ static void post(Attribute& val, Attribute const& attr) {}
+ };
+
     template <typename Attribute>
     struct transform_attribute<Attribute const, Attribute>
     {


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