|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72430 - in trunk/libs/spirit/example/qi/compiler_tutorial: calc7 calc8 conjure conjure_lexer mini_c
From: joel_at_[hidden]
Date: 2011-06-05 22:48:24
Author: djowel
Date: 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
New Revision: 72430
URL: http://svn.boost.org/trac/boost/changeset/72430
Log:
fixed bad code using (...)
Text files modified:
trunk/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp | 18 ++++++++++++++----
trunk/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp | 18 ++++++++++++++----
trunk/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp | 18 ++++++++++++++----
trunk/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp | 18 ++++++++++++++----
trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp | 18 ++++++++++++++----
5 files changed, 70 insertions(+), 20 deletions(-)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/calc7/annotation.hpp 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
@@ -9,6 +9,8 @@
#include <map>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
#include "ast.hpp"
namespace client
@@ -35,17 +37,25 @@
int id;
set_id(int id) : id(id) {}
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
{
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
}
// This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
{
// (no-op) no need for tags
}
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
};
void operator()(ast::operand& ast, Iterator pos) const
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/calc8/annotation.hpp 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
@@ -9,6 +9,8 @@
#include <map>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
#include "ast.hpp"
namespace client
@@ -35,17 +37,25 @@
int id;
set_id(int id) : id(id) {}
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
{
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
}
// This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
{
// (no-op) no need for tags
}
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
};
void operator()(ast::operand& ast, Iterator pos) const
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure/annotation.hpp 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
@@ -9,6 +9,8 @@
#include <map>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
#include "ast.hpp"
namespace client
@@ -35,17 +37,25 @@
int id;
set_id(int id) : id(id) {}
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
{
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
}
// This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
{
// (no-op) no need for tags
}
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
};
void operator()(ast::operand& ast, Iterator pos) const
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure_lexer/annotation.hpp 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
@@ -9,6 +9,8 @@
#include <map>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
#include "ast.hpp"
namespace client
@@ -35,17 +37,25 @@
int id;
set_id(int id) : id(id) {}
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
{
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
}
// This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
{
// (no-op) no need for tags
}
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
};
void operator()(ast::operand& ast, Iterator pos) const
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp 2011-06-05 22:48:23 EDT (Sun, 05 Jun 2011)
@@ -9,6 +9,8 @@
#include <map>
#include <boost/variant/apply_visitor.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/mpl/bool.hpp>
#include "ast.hpp"
namespace client
@@ -35,17 +37,25 @@
int id;
set_id(int id) : id(id) {}
- // This will catch all nodes inheriting from ast::tagged
- void operator()(ast::tagged& x) const
+ template <typename T>
+ void operator()(T& x) const
{
- x.id = id;
+ this->dispatch(x, boost::is_base_of<ast::tagged, T>());
}
// This will catch all nodes except those inheriting from ast::tagged
- void operator()(...) const
+ template <typename T>
+ void dispatch(T& x, boost::mpl::false_) const
{
// (no-op) no need for tags
}
+
+ // This will catch all nodes inheriting from ast::tagged
+ template <typename T>
+ void dispatch(T& x, boost::mpl::true_) const
+ {
+ x.id = id;
+ }
};
void operator()(ast::operand& ast, Iterator pos) const
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