|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68172 - in trunk: boost/proto libs/proto/test
From: eric_at_[hidden]
Date: 2011-01-15 10:24:16
Author: eric_niebler
Date: 2011-01-15 10:24:15 EST (Sat, 15 Jan 2011)
New Revision: 68172
URL: http://svn.boost.org/trac/boost/changeset/68172
Log:
fix handling of operator sfinae in the presence of sub-domains with grammars that differ from the super-domain's
Added:
trunk/libs/proto/test/constrained_ops.cpp (contents, props changed)
Text files modified:
trunk/boost/proto/make_expr.hpp | 1 -
trunk/boost/proto/operators.hpp | 6 ++----
trunk/libs/proto/test/Jamfile.v2 | 2 ++
3 files changed, 4 insertions(+), 5 deletions(-)
Modified: trunk/boost/proto/make_expr.hpp
==============================================================================
--- trunk/boost/proto/make_expr.hpp (original)
+++ trunk/boost/proto/make_expr.hpp 2011-01-15 10:24:15 EST (Sat, 15 Jan 2011)
@@ -33,7 +33,6 @@
#include <boost/mpl/assert.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/utility/enable_if.hpp>
- #include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_cv.hpp>
Modified: trunk/boost/proto/operators.hpp
==============================================================================
--- trunk/boost/proto/operators.hpp (original)
+++ trunk/boost/proto/operators.hpp 2011-01-15 10:24:15 EST (Sat, 15 Jan 2011)
@@ -34,7 +34,7 @@
: boost::lazy_enable_if_c<
boost::mpl::and_<
Trait
- , lazy_matches<result_of::make_expr<Tag, Domain, Arg &>, Grammar>
+ , lazy_matches<result_of::make_expr<Tag, default_domain, Arg &>, Grammar>
>::value
, result_of::make_expr<Tag, Domain, Arg &>
>
@@ -64,9 +64,7 @@
: boost::lazy_enable_if_c<
boost::mpl::and_<
Trait
- , lazy_matches<result_of::as_child<Left>, Grammar>
- , lazy_matches<result_of::as_child<Right>, Grammar>
- , lazy_matches<result_of::make_expr<Tag, Domain, Left &, Right &>, Grammar>
+ , lazy_matches<result_of::make_expr<Tag, default_domain, Left &, Right &>, Grammar>
>::value
, result_of::make_expr<Tag, Domain, Left &, Right &>
>
Modified: trunk/libs/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/proto/test/Jamfile.v2 (original)
+++ trunk/libs/proto/test/Jamfile.v2 2011-01-15 10:24:15 EST (Sat, 15 Jan 2011)
@@ -12,6 +12,7 @@
<toolset>msvc-8.0:<define>_SCL_SECURE_NO_DEPRECATE
<toolset>msvc-8.0:<define>_CRT_SECURE_NO_DEPRECATE
<toolset>msvc-9.0:<define>_SCL_SECURE_NO_DEPRECATE
+ <toolset>msvc-10.0:<define>_SCL_SECURE_NO_DEPRECATE
<toolset>gcc:<cxxflags>-ftemplate-depth-1024
<library>/boost/test//boost_unit_test_framework
<link>static
@@ -20,6 +21,7 @@
test-suite "proto"
:
[ run calculator.cpp ]
+ [ run constrained_ops.cpp ]
[ run deep_copy.cpp ]
[ run display_expr.cpp ]
[ run deduce_domain.cpp ]
Added: trunk/libs/proto/test/constrained_ops.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/proto/test/constrained_ops.cpp 2011-01-15 10:24:15 EST (Sat, 15 Jan 2011)
@@ -0,0 +1,131 @@
+///////////////////////////////////////////////////////////////////////////////
+// constrained_ops.cpp
+//
+// Copyright 2010 Thomas Heller
+// Copyright 2011 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 <boost/proto/proto.hpp>
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+
+typedef proto::terminal<int>::type term;
+
+struct equation;
+
+struct addition:
+ proto::or_
+ <
+ proto::terminal<proto::_>,
+ proto::plus<addition, addition>
+ >
+{};
+
+struct equation:
+ proto::or_
+ <
+ proto::equal_to<addition, addition>
+ >
+{};
+
+template<class Expr>
+struct extension;
+
+struct my_domain:
+ proto::domain
+ <
+ proto::pod_generator<extension>,
+ equation,
+ proto::default_domain
+ >
+{};
+
+template<class Expr>
+struct lhs_extension;
+
+struct my_lhs_domain:
+ proto::domain
+ <
+ proto::pod_generator<lhs_extension>,
+ addition,
+ my_domain
+ >
+{};
+
+template<class Expr>
+struct rhs_extension;
+
+struct my_rhs_domain:
+ proto::domain
+ <
+ proto::pod_generator<rhs_extension>,
+ addition,
+ my_domain
+ >
+{};
+
+template<class Expr>
+struct extension
+{
+ BOOST_PROTO_BASIC_EXTENDS(
+ Expr
+ , extension<Expr>
+ , my_domain
+ )
+
+ void test() const
+ {}
+};
+
+template<class Expr>
+struct lhs_extension
+{
+ BOOST_PROTO_BASIC_EXTENDS(
+ Expr
+ , lhs_extension<Expr>
+ , my_lhs_domain
+ )
+};
+
+template<class Expr>
+struct rhs_extension
+{
+ BOOST_PROTO_BASIC_EXTENDS(
+ Expr
+ , rhs_extension<Expr>
+ , my_rhs_domain
+ )
+};
+
+void test_constrained_ops()
+{
+ lhs_extension<term> const i = {};
+ rhs_extension<term> const j = {};
+
+ proto::assert_matches_not<equation>(i); // false
+ proto::assert_matches_not<equation>(j); // false
+ proto::assert_matches_not<equation>(i + i); // false
+ proto::assert_matches_not<equation>(j + j); // false
+#if 0
+ proto::assert_matches_not<equation>(i + j); // compile error (by design)
+ proto::assert_matches_not<equation>(j + i); // compile error (by design)
+#endif
+ proto::assert_matches<equation>(i == j); // true
+ proto::assert_matches<equation>(i == j + j); // true
+ proto::assert_matches<equation>(i + i == j); // true
+ proto::assert_matches<equation>(i + i == j + j); // true
+}
+
+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 constrained EDSLs");
+ test->add(BOOST_TEST_CASE(&test_constrained_ops));
+ 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