|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67366 - in trunk: boost/proto libs/proto/test
From: eric_at_[hidden]
Date: 2010-12-20 10:54:39
Author: eric_niebler
Date: 2010-12-20 10:54:38 EST (Mon, 20 Dec 2010)
New Revision: 67366
URL: http://svn.boost.org/trac/boost/changeset/67366
Log:
attempted fix for 4910
Added:
trunk/libs/proto/test/display_expr.cpp (contents, props changed)
Text files modified:
trunk/boost/proto/debug.hpp | 15 ++++++++++++---
trunk/libs/proto/test/Jamfile.v2 | 1 +
2 files changed, 13 insertions(+), 3 deletions(-)
Modified: trunk/boost/proto/debug.hpp
==============================================================================
--- trunk/boost/proto/debug.hpp (original)
+++ trunk/boost/proto/debug.hpp 2010-12-20 10:54:38 EST (Mon, 20 Dec 2010)
@@ -92,10 +92,19 @@
std::ostream &sout_;
};
- template<typename Tag>
- std::ostream &operator <<(ostream_wrapper sout_wrap, Tag const &)
+ struct named_any
{
- return sout_wrap.sout_ << BOOST_SP_TYPEID(Tag).name();
+ template<typename T>
+ named_any(T const &)
+ : name_(BOOST_SP_TYPEID(T).name())
+ {}
+
+ char const *name_;
+ };
+
+ std::ostream &operator <<(ostream_wrapper sout_wrap, named_any t)
+ {
+ return sout_wrap.sout_ << t.name_;
}
}
Modified: trunk/libs/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/proto/test/Jamfile.v2 (original)
+++ trunk/libs/proto/test/Jamfile.v2 2010-12-20 10:54:38 EST (Mon, 20 Dec 2010)
@@ -21,6 +21,7 @@
:
[ run calculator.cpp ]
[ run deep_copy.cpp ]
+ [ run display_expr.cpp ]
[ run deduce_domain.cpp ]
[ run examples.cpp ]
[ run lambda.cpp ]
Added: trunk/libs/proto/test/display_expr.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/proto/test/display_expr.cpp 2010-12-20 10:54:38 EST (Mon, 20 Dec 2010)
@@ -0,0 +1,68 @@
+///////////////////////////////////////////////////////////////////////////////
+// display_expr.cpp
+//
+// Copyright 2010 Eric Niebler. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <sstream>
+#include <boost/proto/proto.hpp>
+#include <boost/test/unit_test.hpp>
+
+namespace mpl = boost::mpl;
+namespace proto = boost::proto;
+using proto::_;
+
+struct A {};
+struct B : A {};
+std::ostream& operator<<( std::ostream& out, const A& ) { return out << "this is A!"; }
+
+struct C {};
+
+void test_display_expr()
+{
+ // https://svn.boost.org/trac/boost/ticket/4910
+ proto::terminal<int>::type i = {0};
+
+ {
+ std::stringstream sout;
+ proto::display_expr(i + A(), sout);
+ BOOST_CHECK_EQUAL(sout.str(), std::string(
+ "plus(\n"
+ " terminal(0)\n"
+ " , terminal(this is A!)\n"
+ ")\n"));
+ }
+
+ {
+ std::stringstream sout;
+ proto::display_expr(i + B(), sout);
+ BOOST_CHECK_EQUAL(sout.str(), std::string(
+ "plus(\n"
+ " terminal(0)\n"
+ " , terminal(this is A!)\n"
+ ")\n"));
+ }
+
+ {
+ std::stringstream sout;
+ char const * Cname = BOOST_SP_TYPEID(C).name();
+ proto::display_expr(i + C(), sout);
+ BOOST_CHECK_EQUAL(sout.str(), std::string(
+ "plus(\n"
+ " terminal(0)\n"
+ " , terminal(") + Cname + std::string(")\n"
+ ")\n"));
+ }
+}
+
+using namespace boost::unit_test;
+///////////////////////////////////////////////////////////////////////////////
+// init_unit_test_suite
+//
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("test display_expr() function");
+ test->add(BOOST_TEST_CASE(&test_display_expr));
+ return test;
+}
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