Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49691 - in trunk: boost/spirit/home/phoenix/operator libs/spirit/phoenix/test/operator
From: steven_at_[hidden]
Date: 2008-11-11 21:59:10


Author: steven_watanabe
Date: 2008-11-11 21:59:10 EST (Tue, 11 Nov 2008)
New Revision: 49691
URL: http://svn.boost.org/trac/boost/changeset/49691

Log:
overloads of the io operators for ostream/istream to fix ambiguity with fusion
Text files modified:
   trunk/boost/spirit/home/phoenix/operator/io.hpp | 15 +++++++++++++++
   trunk/libs/spirit/phoenix/test/operator/io_tests.cpp | 3 +++
   2 files changed, 18 insertions(+), 0 deletions(-)

Modified: trunk/boost/spirit/home/phoenix/operator/io.hpp
==============================================================================
--- trunk/boost/spirit/home/phoenix/operator/io.hpp (original)
+++ trunk/boost/spirit/home/phoenix/operator/io.hpp 2008-11-11 21:59:10 EST (Tue, 11 Nov 2008)
@@ -30,6 +30,21 @@
         return compose<shift_right_eval>(phoenix::ref(a0), a1);
     }
 
+ // resolve ambiguities with fusion.
+ template <typename T1>
+ inline typename detail::enable_if_ostream<std::ostream, T1>::type
+ operator<<(std::ostream& a0, actor<T1> const& a1)
+ {
+ return compose<shift_left_eval>(phoenix::ref(a0), a1);
+ }
+
+ template <typename T1>
+ inline typename detail::enable_if_istream<std::istream, T1>::type
+ operator>>(std::istream& a0, actor<T1> const& a1)
+ {
+ return compose<shift_right_eval>(phoenix::ref(a0), a1);
+ }
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // overloads for I/O manipulators.

Modified: trunk/libs/spirit/phoenix/test/operator/io_tests.cpp
==============================================================================
--- trunk/libs/spirit/phoenix/test/operator/io_tests.cpp (original)
+++ trunk/libs/spirit/phoenix/test/operator/io_tests.cpp 2008-11-11 21:59:10 EST (Tue, 11 Nov 2008)
@@ -15,6 +15,8 @@
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 
+#include <boost/fusion/include/io.hpp>
+
 using namespace boost::phoenix;
 using namespace boost::phoenix::arg_names;
 using namespace std;
@@ -37,6 +39,7 @@
 
     (cout << val(hello) << world << ", you da man!\n")();
     for_each(v.begin(), v.end(), cout << arg1 << ',');
+ (cout << arg1 + 1)(i100);
 
     (cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100);
 


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