|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67233 - in trunk: boost/proto/transform libs/proto/doc/reference/transform libs/proto/test
From: eric_at_[hidden]
Date: 2010-12-14 22:33:32
Author: eric_niebler
Date: 2010-12-14 22:33:31 EST (Tue, 14 Dec 2010)
New Revision: 67233
URL: http://svn.boost.org/trac/boost/changeset/67233
Log:
fix regression in make transform, add make regression tests
Added:
trunk/libs/proto/test/make.cpp (contents, props changed)
Text files modified:
trunk/boost/proto/transform/make.hpp | 11 ++---------
trunk/libs/proto/doc/reference/transform/make.xml | 12 ------------
trunk/libs/proto/test/Jamfile.v2 | 1 +
3 files changed, 3 insertions(+), 21 deletions(-)
Modified: trunk/boost/proto/transform/make.hpp
==============================================================================
--- trunk/boost/proto/transform/make.hpp (original)
+++ trunk/boost/proto/transform/make.hpp 2010-12-14 22:33:31 EST (Tue, 14 Dec 2010)
@@ -82,7 +82,7 @@
template<
typename T
, typename Expr, typename State, typename Data
- , bool Applied, bool IsTransform = is_transform<T>::value
+ , bool Applied
>
struct nested_type_if
{
@@ -90,15 +90,8 @@
static bool const applied = false;
};
- template<typename T, typename Expr, typename State, typename Data, bool Applied>
- struct nested_type_if<T, Expr, State, Data, Applied, true>
- : uncvref<typename T::template impl<Expr, State, Data>::result_type>
- {
- static bool const applied = true;
- };
-
template<typename T, typename Expr, typename State, typename Data>
- struct nested_type_if<T, Expr, State, Data, true, false>
+ struct nested_type_if<T, Expr, State, Data, true>
: nested_type<T>
{
static bool const applied = true;
Modified: trunk/libs/proto/doc/reference/transform/make.xml
==============================================================================
--- trunk/libs/proto/doc/reference/transform/make.xml (original)
+++ trunk/libs/proto/doc/reference/transform/make.xml 2010-12-14 22:33:31 EST (Tue, 14 Dec 2010)
@@ -243,18 +243,6 @@
<para>
If any substitutions took place in the above step and
<computeroutput>
- <classname>is_transform</classname><S<X<subscript>0</subscript>',...X<subscript>n</subscript>'> >::value
- </computeroutput> is
- <computeroutput>true</computeroutput>, the result type is
- <computeroutput>
- boost::result_of<<classname>proto::when</classname><<classname>_</classname>, S<X<subscript>0</subscript>',...X<subscript>n</subscript>'> >(Expr, State, Data)>::type
- </computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- Otherwise, If any substitutions took place in the above step and
- <computeroutput>
S<X<subscript>0</subscript>',...X<subscript>n</subscript>'>
</computeroutput> has a nested
<computeroutput>type</computeroutput> typedef, the result type is
Modified: trunk/libs/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/proto/test/Jamfile.v2 (original)
+++ trunk/libs/proto/test/Jamfile.v2 2010-12-14 22:33:31 EST (Tue, 14 Dec 2010)
@@ -30,6 +30,7 @@
[ run proto_fusion_s.cpp ]
[ run toy_spirit.cpp ]
[ run toy_spirit2.cpp ]
+ [ run make.cpp ]
[ run noinvoke.cpp ]
[ run mem_ptr.cpp : : : <toolset>msvc:<cxxflags>/wd4355 ]
[ compile bug2407.cpp ]
Added: trunk/libs/proto/test/make.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/proto/test/make.cpp 2010-12-14 22:33:31 EST (Tue, 14 Dec 2010)
@@ -0,0 +1,98 @@
+///////////////////////////////////////////////////////////////////////////////
+// make.hpp
+//
+// Copyright 2008 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/core.hpp>
+#include <boost/proto/transform/arg.hpp>
+#include <boost/proto/transform/make.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/test/unit_test.hpp>
+
+namespace mpl = boost::mpl;
+namespace proto = boost::proto;
+using proto::_;
+
+template<typename T>
+struct type2type {};
+
+template<typename T>
+struct wrapper
+{
+ T t_;
+ explicit wrapper(T const & t = T()) : t_(t) {}
+};
+
+template<typename T>
+struct careful
+{
+ typedef typename T::not_there not_there;
+};
+
+// Test that when no substitution is done, we don't instantiate templates
+struct MakeTest1
+ : proto::make< type2type< careful<int> > >
+{};
+
+void make_test1()
+{
+ proto::terminal<int>::type i = {42};
+ type2type< careful<int> > res = MakeTest1()(i);
+}
+
+// Test that when substitution is done, and there is no nested ::type
+// typedef, the result is the wrapper
+struct MakeTest2
+ : proto::make< wrapper< proto::_value > >
+{};
+
+void make_test2()
+{
+ proto::terminal<int>::type i = {42};
+ wrapper<int> res = MakeTest2()(i);
+ BOOST_CHECK_EQUAL(res.t_, 0);
+}
+
+// Test that when substitution is done, and there is no nested ::type
+// typedef, the result is the wrapper
+struct MakeTest3
+ : proto::make< wrapper< proto::_value >(proto::_value) >
+{};
+
+void make_test3()
+{
+ proto::terminal<int>::type i = {42};
+ wrapper<int> res = MakeTest3()(i);
+ BOOST_CHECK_EQUAL(res.t_, 42);
+}
+
+// Test that when substitution is done, and there is no nested ::type
+// typedef, the result is the wrapper
+struct MakeTest4
+ : proto::make< mpl::identity< proto::_value >(proto::_value) >
+{};
+
+void make_test4()
+{
+ proto::terminal<int>::type i = {42};
+ int res = MakeTest4()(i);
+ BOOST_CHECK_EQUAL(res, 42);
+}
+
+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 the make transform");
+
+ test->add(BOOST_TEST_CASE(&make_test1));
+ test->add(BOOST_TEST_CASE(&make_test2));
+ test->add(BOOST_TEST_CASE(&make_test3));
+ test->add(BOOST_TEST_CASE(&make_test4));
+
+ 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