Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52876 - trunk/libs/spirit/example/karma
From: hartmut.kaiser_at_[hidden]
Date: 2009-05-10 12:38:02


Author: hkaiser
Date: 2009-05-10 12:38:02 EDT (Sun, 10 May 2009)
New Revision: 52876
URL: http://svn.boost.org/trac/boost/changeset/52876

Log:
Spirit: Fixing ADL problem in example karma/calc2_ast_vm.cpp
Text files modified:
   trunk/libs/spirit/example/karma/calc2_ast_vm.cpp | 6 +++---
   trunk/libs/spirit/example/karma/calc2_ast_vm.hpp | 19 ++++++++++++-------
   2 files changed, 15 insertions(+), 10 deletions(-)

Modified: trunk/libs/spirit/example/karma/calc2_ast_vm.cpp
==============================================================================
--- trunk/libs/spirit/example/karma/calc2_ast_vm.cpp (original)
+++ trunk/libs/spirit/example/karma/calc2_ast_vm.cpp 2009-05-10 12:38:02 EDT (Sun, 10 May 2009)
@@ -17,15 +17,15 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include <boost/config/warning_disable.hpp>
 
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/karma.hpp>
-
 #include <iostream>
 #include <vector>
 #include <string>
 
 #include "calc2_ast_vm.hpp"
 
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/karma.hpp>
+
 using namespace boost::spirit;
 using namespace boost::spirit::ascii;
 

Modified: trunk/libs/spirit/example/karma/calc2_ast_vm.hpp
==============================================================================
--- trunk/libs/spirit/example/karma/calc2_ast_vm.hpp (original)
+++ trunk/libs/spirit/example/karma/calc2_ast_vm.hpp 2009-05-10 12:38:02 EDT (Sun, 10 May 2009)
@@ -19,6 +19,7 @@
 #define SPIRIT_EXAMPLE_CALC2_AST_APR_30_2008_1011AM
 
 #include <boost/variant/recursive_variant.hpp>
+#include <boost/variant/get.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/spirit/include/phoenix_statement.hpp>
@@ -43,10 +44,10 @@
 
     // expose variant types
     typedef type::types types;
-
+
     // expose variant functionality
     int which() const { return expr.which(); }
-
+
     // constructors
     expression_ast()
       : expr(nil()) {}
@@ -59,10 +60,10 @@
 
     expression_ast(unsigned int expr)
       : expr(expr) {}
-
+
     expression_ast(type const& expr)
       : expr(expr) {}
-
+
     expression_ast& operator+=(expression_ast const& rhs);
     expression_ast& operator-=(expression_ast const& rhs);
     expression_ast& operator*=(expression_ast const& rhs);
@@ -72,10 +73,14 @@
 };
 
 // expose variant functionality
-template <typename T>
-inline T get(expression_ast const& expr)
+namespace boost
 {
- return boost::get<T>(expr.expr);
+ // this function has to live in namespace boost for ADL to correctly find it
+ template <typename T>
+ inline T get(expression_ast const& expr)
+ {
+ return boost::get<T>(expr.expr);
+ }
 }
 
 enum byte_code


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