Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61699 - in trunk/boost/spirit/home: karma/nonterminal qi/nonterminal
From: dgregor_at_[hidden]
Date: 2010-04-30 03:04:40


Author: dgregor
Date: 2010-04-30 03:04:39 EDT (Fri, 30 Apr 2010)
New Revision: 61699
URL: http://svn.boost.org/trac/boost/changeset/61699

Log:
We can't use the incomplete type simple_trace (actually, there are two
of these) inside a template in a non-dependent expression. Use a
little template trickery to make the expression dependent, delaying
type-checking until later, which simple_trace will be complete.

Text files modified:
   trunk/boost/spirit/home/karma/nonterminal/debug_handler.hpp | 16 +++++++++++++++-
   trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp | 16 +++++++++++++++-
   2 files changed, 30 insertions(+), 2 deletions(-)

Modified: trunk/boost/spirit/home/karma/nonterminal/debug_handler.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/nonterminal/debug_handler.hpp (original)
+++ trunk/boost/spirit/home/karma/nonterminal/debug_handler.hpp 2010-04-30 03:04:39 EDT (Fri, 30 Apr 2010)
@@ -86,6 +86,18 @@
 
     struct simple_trace;
 
+ namespace detail {
+ // This class provides an extra level of indirection through a
+ // template to produce the simple_trace type. This way, the use
+ // of simple_trace below is hidden behind a dependent type, so
+ // that compilers eagerly type-checking template definitions
+ // won't complain that simple_trace is incomplete.
+ template<typename T>
+ struct get_simple_trace {
+ typedef simple_trace type;
+ };
+ }
+
     template <typename OutputIterator
       , typename T1, typename T2, typename T3, typename T4>
     void debug(rule<OutputIterator, T1, T2, T3, T4>& r)
@@ -100,7 +112,9 @@
               , typename rule_type::properties
               , simple_trace>
         debug_handler;
- r.f = debug_handler(r.f, simple_trace(), r.name());
+ typedef typename karma::detail::get_simple_trace<OutputIterator>::type
+ trace;
+ r.f = debug_handler(r.f, trace(), r.name());
     }
 
 }}}

Modified: trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp 2010-04-30 03:04:39 EDT (Fri, 30 Apr 2010)
@@ -90,6 +90,18 @@
 
     struct simple_trace;
 
+ namespace detail {
+ // This class provides an extra level of indirection through a
+ // template to produce the simple_trace type. This way, the use
+ // of simple_trace below is hidden behind a dependent type, so
+ // that compilers eagerly type-checking template definitions
+ // won't complain that simple_trace is incomplete.
+ template<typename T>
+ struct get_simple_trace {
+ typedef simple_trace type;
+ };
+ }
+
     template <typename Iterator
       , typename T1, typename T2, typename T3, typename T4>
     void debug(rule<Iterator, T1, T2, T3, T4>& r)
@@ -103,7 +115,9 @@
               , typename rule_type::skipper_type
               , simple_trace>
         debug_handler;
- r.f = debug_handler(r.f, simple_trace(), r.name());
+
+ typedef typename qi::detail::get_simple_trace<Iterator>::type trace;
+ r.f = debug_handler(r.f, trace(), r.name());
     }
 
 }}}


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