Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76929 - trunk/libs/spirit/example/qi
From: joel_at_[hidden]
Date: 2012-02-07 01:13:51


Author: djowel
Date: 2012-02-07 01:13:50 EST (Tue, 07 Feb 2012)
New Revision: 76929
URL: http://svn.boost.org/trac/boost/changeset/76929

Log:
Support for BOOST_SPIRIT_AUTO and qi::copy.
Text files modified:
   trunk/libs/spirit/example/qi/typeof.cpp | 26 +++++++++++++++++---------
   1 files changed, 17 insertions(+), 9 deletions(-)

Modified: trunk/libs/spirit/example/qi/typeof.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/typeof.cpp (original)
+++ trunk/libs/spirit/example/qi/typeof.cpp 2012-02-07 01:13:50 EST (Tue, 07 Feb 2012)
@@ -6,7 +6,8 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 #include <boost/spirit/include/qi.hpp>
-#include <boost/typeof/typeof.hpp>
+#include <boost/spirit/include/qi_copy.hpp>
+#include <boost/spirit/include/support_auto.hpp>
 #include <iostream>
 #include <string>
 
@@ -14,13 +15,6 @@
 // Main program
 ///////////////////////////////////////////////////////////////////////////////
 
-#define BOOST_SPIRIT_AUTO(domain_, name, expr) \
- typedef boost::proto::result_of:: \
- deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \
- BOOST_SPIRIT_ASSERT_MATCH( \
- boost::spirit::domain_::domain, name##_expr_type); \
- BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
-
 int
 main()
 {
@@ -28,9 +22,23 @@
     using boost::spirit::ascii::char_;
     using boost::spirit::qi::parse;
     typedef std::string::const_iterator iterator_type;
-
+
+///////////////////////////////////////////////////////////////////////////////
+// this works for non-c++11 compilers
+#ifdef BOOST_NO_AUTO_DECLARATIONS
+
     BOOST_SPIRIT_AUTO(qi, comment, "/*" >> *(char_ - "*/") >> "*/");
 
+///////////////////////////////////////////////////////////////////////////////
+// but this is better for c++11 compilers with auto
+#else
+
+ using boost::spirit::qi::copy;
+
+ auto comment = copy("/*" >> *(char_ - "*/") >> "*/");
+
+#endif
+
     std::string str = "/*This is a comment*/";
     std::string::const_iterator iter = str.begin();
     std::string::const_iterator end = str.end();


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