Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75618 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-22 18:46:45


Author: danieljames
Date: 2011-11-22 18:46:45 EST (Tue, 22 Nov 2011)
New Revision: 75618
URL: http://svn.boost.org/trac/boost/changeset/75618

Log:
Quickbook: Add static check that Scanner is what the code assumes.
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/grammar.hpp | 17 ++++++++++-------
   1 files changed, 10 insertions(+), 7 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/grammar.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/grammar.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/grammar.hpp 2011-11-22 18:46:45 EST (Tue, 22 Nov 2011)
@@ -24,6 +24,11 @@
     typedef cl::scanner<parse_iterator, cl::scanner_policies <
         cl::iteration_policy, cl::match_policy, cl::action_policy> > scanner;
 
+ template <typename Scanner>
+ struct Scanner_must_be_the_quickbook_scanner_typedef;
+ template <>
+ struct Scanner_must_be_the_quickbook_scanner_typedef<scanner> {};
+
     struct grammar
         : public cl::grammar<grammar>
     {
@@ -31,14 +36,12 @@
             : start_rule(start_rule) {}
 
         template <typename Scanner>
- struct definition {
- // TODO: Statically assert that Scanner == scanner.
-
+ struct definition :
+ Scanner_must_be_the_quickbook_scanner_typedef<Scanner>
+ {
             definition(grammar const& self) : start_rule(self.start_rule) {}
-
- cl::rule<Scanner> const& start() const { return start_rule; }
-
- cl::rule<Scanner> const& start_rule;
+ cl::rule<scanner> const& start() const { return start_rule; }
+ cl::rule<scanner> const& start_rule;
         };
 
         cl::rule<scanner> const& start_rule;


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