|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-04-07 20:17:54
Author: eric_niebler
Date: 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
New Revision: 44110
URL: http://svn.boost.org/trac/boost/changeset/44110
Log:
s/functor/functional
Text files modified:
branches/proto/v4/boost/proto/debug.hpp | 8 +-
branches/proto/v4/boost/proto/deep_copy.hpp | 4
branches/proto/v4/boost/proto/eval.hpp | 2
branches/proto/v4/boost/proto/fusion.hpp | 8 +-
branches/proto/v4/boost/proto/make_expr.hpp | 26 +++++-----
branches/proto/v4/boost/proto/proto_fwd.hpp | 12 ++--
branches/proto/v4/boost/proto/traits.hpp | 10 +-
branches/proto/v4/boost/xpressive/detail/core/matcher/action_matcher.hpp | 13 ++--
branches/proto/v4/boost/xpressive/regex_primitives.hpp | 2
branches/proto/v4/libs/proto/doc/construction.qbk | 18 +++---
branches/proto/v4/libs/proto/doc/evaluation.qbk | 2
branches/proto/v4/libs/proto/example/lambda.cpp | 2
branches/proto/v4/libs/proto/test/calculator.cpp | 8 +-
branches/proto/v4/libs/proto/test/make_expr.cpp | 102 ++++++++++++++++++++++++++++++++-------
14 files changed, 142 insertions(+), 75 deletions(-)
Modified: branches/proto/v4/boost/proto/debug.hpp
==============================================================================
--- branches/proto/v4/boost/proto/debug.hpp (original)
+++ branches/proto/v4/boost/proto/debug.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -113,7 +113,7 @@
#undef BOOST_PROTO_DEFINE_TAG_NAME
}
- namespace functor
+ namespace functional
{
/// \brief Pretty-print a Proto expression tree.
///
@@ -186,7 +186,7 @@
/// \brief Pretty-print a Proto expression tree.
///
- /// \note Equivalent to <tt>functor::display_expr(0, sout)(expr)</tt>
+ /// \note Equivalent to <tt>functional::display_expr(0, sout)(expr)</tt>
/// \param expr The Proto expression tree to pretty-print
/// \param sout The \c ostream to which the output should be
/// written. If not specified, defaults to
@@ -194,7 +194,7 @@
template<typename Expr>
void display_expr(Expr const &expr, std::ostream &sout)
{
- functor::display_expr(sout, 0)(expr);
+ functional::display_expr(sout, 0)(expr);
}
/// \overload
@@ -202,7 +202,7 @@
template<typename Expr>
void display_expr(Expr const &expr)
{
- functor::display_expr()(expr);
+ functional::display_expr()(expr);
}
}}
Modified: branches/proto/v4/boost/proto/deep_copy.hpp
==============================================================================
--- branches/proto/v4/boost/proto/deep_copy.hpp (original)
+++ branches/proto/v4/boost/proto/deep_copy.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -72,7 +72,7 @@
};
}
- namespace functor
+ namespace functional
{
/// \brief A PolymorphicFunctionObject type for deep-copying
/// Proto expression trees.
@@ -124,7 +124,7 @@
/// \attention Terminals of reference-to-array type and of
/// reference-to-function type are left unchanged.
///
- /// \sa proto::functor::deep_copy.
+ /// \sa proto::functional::deep_copy.
template<typename Expr>
typename proto::result_of::deep_copy<Expr>::type
deep_copy(Expr const &expr)
Modified: branches/proto/v4/boost/proto/eval.hpp
==============================================================================
--- branches/proto/v4/boost/proto/eval.hpp (original)
+++ branches/proto/v4/boost/proto/eval.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -33,7 +33,7 @@
};
}
- namespace functor
+ namespace functional
{
/// \brief A PolymorphicFunctionObject type for
/// evaluating a given Proto expression with a given
Modified: branches/proto/v4/boost/proto/fusion.hpp
==============================================================================
--- branches/proto/v4/boost/proto/fusion.hpp (original)
+++ branches/proto/v4/boost/proto/fusion.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -118,7 +118,7 @@
}
- namespace functor
+ namespace functional
{
/// \brief A PolymorphicFunctionObject type that returns a "flattened"
/// view of a Proto expression tree.
@@ -239,21 +239,21 @@
/// INTERNAL ONLY
///
template<>
- struct is_callable<functor::flatten>
+ struct is_callable<functional::flatten>
: mpl::true_
{};
/// INTERNAL ONLY
///
template<>
- struct is_callable<functor::pop_front>
+ struct is_callable<functional::pop_front>
: mpl::true_
{};
/// INTERNAL ONLY
///
template<>
- struct is_callable<functor::reverse>
+ struct is_callable<functional::reverse>
: mpl::true_
{};
Modified: branches/proto/v4/boost/proto/make_expr.hpp
==============================================================================
--- branches/proto/v4/boost/proto/make_expr.hpp (original)
+++ branches/proto/v4/boost/proto/make_expr.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -366,8 +366,8 @@
{
return typename mpl::if_<
is_reference_wrapper<T>
- , functor::as_child<Domain>
- , functor::as_expr<Domain>
+ , functional::as_child<Domain>
+ , functional::as_expr<Domain>
>::type()(static_cast<unref_type &>(t));
}
};
@@ -385,7 +385,7 @@
static type call(T &t)
{
- return functor::as_child<Domain>()(static_cast<unref_type &>(t));
+ return functional::as_child<Domain>()(static_cast<unref_type &>(t));
}
};
@@ -650,15 +650,15 @@
};
}
- namespace functor
+ namespace functional
{
/// \brief A callable function object equivalent to the
/// \c proto::make_expr() function.
///
- /// In all cases, <tt>functor::make_expr\<Tag, Domain\>()(a0, ... aN)</tt>
+ /// In all cases, <tt>functional::make_expr\<Tag, Domain\>()(a0, ... aN)</tt>
/// is equivalent to <tt>proto::make_expr\<Tag, Domain\>(a0, ... aN)</tt>.
///
- /// <tt>functor::make_expr\<Tag\>()(a0, ... aN)</tt>
+ /// <tt>functional::make_expr\<Tag\>()(a0, ... aN)</tt>
/// is equivalent to <tt>proto::make_expr\<Tag\>(a0, ... aN)</tt>.
template<typename Tag, typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= deduce_domain)>
struct make_expr
@@ -711,10 +711,10 @@
/// \brief A callable function object equivalent to the
/// \c proto::unpack_expr() function.
///
- /// In all cases, <tt>functor::unpack_expr\<Tag, Domain\>()(seq)</tt>
+ /// In all cases, <tt>functional::unpack_expr\<Tag, Domain\>()(seq)</tt>
/// is equivalent to <tt>proto::unpack_expr\<Tag, Domain\>(seq)</tt>.
///
- /// <tt>functor::unpack_expr\<Tag\>()(seq)</tt>
+ /// <tt>functional::unpack_expr\<Tag\>()(seq)</tt>
/// is equivalent to <tt>proto::unpack_expr\<Tag\>(seq)</tt>.
template<typename Tag, typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= deduce_domain)>
struct unpack_expr
@@ -799,7 +799,7 @@
BOOST_PROTO_CALLABLE()
};
- } // namespace functor
+ } // namespace functional
/// \brief Construct an expression of the requested tag type
/// with a domain and with the specified arguments as children.
@@ -922,21 +922,21 @@
/// INTERNAL ONLY
///
template<typename Tag, typename Domain>
- struct is_callable<functor::make_expr<Tag, Domain> >
+ struct is_callable<functional::make_expr<Tag, Domain> >
: mpl::true_
{};
/// INTERNAL ONLY
///
template<typename Tag, typename Domain>
- struct is_callable<functor::unpack_expr<Tag, Domain> >
+ struct is_callable<functional::unpack_expr<Tag, Domain> >
: mpl::true_
{};
/// INTERNAL ONLY
///
template<typename Tag, typename Domain>
- struct is_callable<functor::unfused_expr<Tag, Domain> >
+ struct is_callable<functional::unfused_expr<Tag, Domain> >
: mpl::true_
{};
@@ -945,7 +945,7 @@
{
template<typename Sig>
struct result
- : functor::make_expr<Tag, Domain>::template result<Sig>
+ : functional::make_expr<Tag, Domain>::template result<Sig>
{};
#define M0(Z, N, DATA) \
Modified: branches/proto/v4/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v4/boost/proto/proto_fwd.hpp (original)
+++ branches/proto/v4/boost/proto/proto_fwd.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -549,7 +549,7 @@
using namespace op;
- namespace functor
+ namespace functional
{
struct left;
struct right;
@@ -631,11 +631,11 @@
struct reverse;
}
- typedef functor::flatten _flatten;
- typedef functor::pop_front _pop_front;
- typedef functor::reverse _reverse;
- typedef functor::eval _eval;
- typedef functor::deep_copy _deep_copy;
+ typedef functional::flatten _flatten;
+ typedef functional::pop_front _pop_front;
+ typedef functional::reverse _reverse;
+ typedef functional::eval _eval;
+ typedef functional::deep_copy _deep_copy;
template<typename Tag, typename Domain = deduce_domain>
struct _make_expr;
Modified: branches/proto/v4/boost/proto/traits.hpp
==============================================================================
--- branches/proto/v4/boost/proto/traits.hpp (original)
+++ branches/proto/v4/boost/proto/traits.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -1517,7 +1517,7 @@
#undef BOOST_PROTO_CHILD
#undef BOOST_PROTO_IMPLICIT_ARG
- namespace functor
+ namespace functional
{
/// \brief A callable PolymorphicFunctionObject that is
/// equivalent to the \c as_expr() function.
@@ -2076,28 +2076,28 @@
/// INTERNAL ONLY
///
template<typename Domain>
- struct is_callable<functor::as_expr<Domain> >
+ struct is_callable<functional::as_expr<Domain> >
: mpl::true_
{};
/// INTERNAL ONLY
///
template<typename Domain>
- struct is_callable<functor::as_child<Domain> >
+ struct is_callable<functional::as_child<Domain> >
: mpl::true_
{};
/// INTERNAL ONLY
///
template<long N>
- struct is_callable<functor::child_c<N> >
+ struct is_callable<functional::child_c<N> >
: mpl::true_
{};
/// INTERNAL ONLY
///
template<typename N>
- struct is_callable<functor::child<N> >
+ struct is_callable<functional::child<N> >
: mpl::true_
{};
Modified: branches/proto/v4/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ branches/proto/v4/boost/xpressive/detail/core/matcher/action_matcher.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -22,6 +22,7 @@
#include <boost/assert.hpp>
#include <boost/mpl/if.hpp>
#include <boost/throw_exception.hpp>
+#include <boost/utility/result_of.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
@@ -281,7 +282,7 @@
result_type;
result_type operator ()(
- typename impl::expr_param expr
+ typename impl::expr_param
, typename impl::state_param state
, typename impl::data_param data
) const
@@ -416,8 +417,8 @@
result_type operator ()(
typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ , typename impl::state_param
+ , typename impl::data_param
) const
{
return result_type::make(proto::value(expr));
@@ -463,13 +464,13 @@
{
// Bind the arguments
typedef
- typename BindActionArgs::template impl<
+ typename boost::result_of<BindActionArgs(
Actor const &
, match_state<BidiIter> &
, int const &
- >::result_type
+ )>::type
action_type;
-
+
action<action_type> actor(BindActionArgs()(this->actor_, state, this->sub_));
// Put the action in the action list
Modified: branches/proto/v4/boost/xpressive/regex_primitives.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/regex_primitives.hpp (original)
+++ branches/proto/v4/boost/xpressive/regex_primitives.hpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -585,7 +585,7 @@
#ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
template<typename Literal> detail::unspecified as_xpr(Literal const &literal) { return 0; }
#else
-proto::functor::as_expr<> const as_xpr = {};
+proto::functional::as_expr<> const as_xpr = {};
#endif
///////////////////////////////////////////////////////////////////////////////
Modified: branches/proto/v4/libs/proto/doc/construction.qbk
==============================================================================
--- branches/proto/v4/libs/proto/doc/construction.qbk (original)
+++ branches/proto/v4/libs/proto/doc/construction.qbk 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -258,7 +258,7 @@
// pop_front() removes the "fun" child
fusion::pop_front(fun(1,2,3,4))
// Extract the ints from the terminal nodes
- , functor::child<>()
+ , functional::child<>()
)
, display()
);
@@ -284,7 +284,7 @@
fusion::for_each(
fusion::transform(
_1 + 2 + 3 + 4
- , functor::child<>()
+ , functional::child<>()
)
, display()
);
@@ -303,7 +303,7 @@
fusion::for_each(
fusion::transform(
proto::flatten(_1 + 2 + 3 + 4)
- , functor::child<>()
+ , functional::child<>()
)
, display()
);
@@ -560,7 +560,7 @@
};
}
- namespace functor
+ namespace functional
{
// A callable function object equivalent of the
// make_expr() function.
@@ -750,7 +750,7 @@
};
}
- namespace functor
+ namespace functional
{
// A callable function object equivalent of the
// unpack_expr() function.
@@ -805,7 +805,7 @@
As with _make_expr_, _unpack_expr_ has a corresponding metafunction
in the `proto::result_of` namespace for calculating its return type, as
-well as a callable function object form in the `proto::functor`
+well as a callable function object form in the `proto::functional`
namespace.
One last interesting point about _unpack_expr_: Proto expression
@@ -838,14 +838,14 @@
, BOUNDARGS \
)
-The `proto::functor::make_expr<>` function object makes it very simple
+The `proto::functional::make_expr<>` function object makes it very simple
to create something that behaves like an expression factory function. For
instance, the following defines a factory named `invert()` that
"complements" its argument; that is, it builds a new node with type
`tag::complement` as if Proto's `operator~` had been applied:
// invert(x) is now a synonym for ~proto::as_expr(x)
- proto::functor::make_expr<proto::tag::complement> const invert = {};
+ proto::functional::make_expr<proto::tag::complement> const invert = {};
Such named "operators" are very important for domain-specific embedded
languages. What's more, when defined as above, the `invert()` factory can
@@ -867,7 +867,7 @@
Now, users of your function can invoke it like this: `foo<int>("foo!")`. If
you want to seamlessly handle up to /N/ argument, you have to write all /N/
-overloads yourself --- `functor::make_expr<>` can't help you. For this
+overloads yourself --- `functional::make_expr<>` can't help you. For this
situation, Proto provides the `BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE()`
macro. You can invoke it as follows:
Modified: branches/proto/v4/libs/proto/doc/evaluation.qbk
==============================================================================
--- branches/proto/v4/libs/proto/doc/evaluation.qbk (original)
+++ branches/proto/v4/libs/proto/doc/evaluation.qbk 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -44,7 +44,7 @@
};
}
- namespace functor
+ namespace functional
{
// A callable function object type for evaluating
// a Proto expression with a certain context.
Modified: branches/proto/v4/libs/proto/example/lambda.cpp
==============================================================================
--- branches/proto/v4/libs/proto/example/lambda.cpp (original)
+++ branches/proto/v4/libs/proto/example/lambda.cpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -4,7 +4,7 @@
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-// This example builds a simple but functor lambda library using Proto.
+// This example builds a simple but functional lambda library using Proto.
#include <iostream>
#include <algorithm>
Modified: branches/proto/v4/libs/proto/test/calculator.cpp
==============================================================================
--- branches/proto/v4/libs/proto/test/calculator.cpp (original)
+++ branches/proto/v4/libs/proto/test/calculator.cpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -61,11 +61,11 @@
};
template<typename Fun, typename Expr>
-struct functor
+struct functional
{
typedef typename proto::result_of::eval<Expr, Fun>::type result_type;
- functor(Expr const &expr)
+ functional(Expr const &expr)
: expr_(expr)
{}
@@ -81,9 +81,9 @@
};
template<typename Fun, typename Expr>
-functor<Fun, Expr> as(Expr const &expr)
+functional<Fun, Expr> as(Expr const &expr)
{
- return functor<Fun, Expr>(expr);
+ return functional<Fun, Expr>(expr);
}
void test_calculator()
Modified: branches/proto/v4/libs/proto/test/make_expr.cpp
==============================================================================
--- branches/proto/v4/libs/proto/test/make_expr.cpp (original)
+++ branches/proto/v4/libs/proto/test/make_expr.cpp 2008-04-07 20:17:52 EDT (Mon, 07 Apr 2008)
@@ -9,6 +9,7 @@
#include <boost/version.hpp>
#include <boost/proto/core.hpp>
#include <boost/proto/transform.hpp>
+#include <boost/utility/addressof.hpp>
#if BOOST_VERSION >= 103500
#include <boost/fusion/tuple.hpp>
#else
@@ -75,39 +76,39 @@
void test_make_expr_functional()
{
int i = 42;
- terminal<int>::type t1 = functor::make_expr<tag::terminal>()(1);
- terminal<int>::type t2 = functor::make_expr<tag::terminal>()(i);
- unary_plus<terminal<int>::type>::type p1 = functor::make_expr<tag::unary_plus>()(1);
- unary_plus<terminal<int>::type>::type p2 = functor::make_expr<tag::unary_plus>()(i);
+ terminal<int>::type t1 = functional::make_expr<tag::terminal>()(1);
+ terminal<int>::type t2 = functional::make_expr<tag::terminal>()(i);
+ unary_plus<terminal<int>::type>::type p1 = functional::make_expr<tag::unary_plus>()(1);
+ unary_plus<terminal<int>::type>::type p2 = functional::make_expr<tag::unary_plus>()(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int>::type> >::type> p3 = functor::make_expr<tag::unary_plus, mydomain>()(i);
+ ewrap<unary_plus<ewrap<terminal<int>::type> >::type> p3 = functional::make_expr<tag::unary_plus, mydomain>()(i);
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
ewrap<plus<
ewrap<unary_plus<ewrap<terminal<int>::type> >::type>
, ewrap<terminal<int>::type>
- >::type> p4 = functor::make_expr<tag::plus, mydomain>()(p3, 0);
+ >::type> p4 = functional::make_expr<tag::plus, mydomain>()(p3, 0);
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
void test_make_expr_functional_ref()
{
int i = 42;
- terminal<int const &>::type t1 = functor::make_expr<tag::terminal>()(boost::cref(1)); // DANGEROUS
- terminal<int &>::type t2 = functor::make_expr<tag::terminal>()(boost::ref(i));
+ terminal<int const &>::type t1 = functional::make_expr<tag::terminal>()(boost::cref(1)); // DANGEROUS
+ terminal<int &>::type t2 = functional::make_expr<tag::terminal>()(boost::ref(i));
BOOST_CHECK_EQUAL(&i, &proto::value(t2));
- unary_plus<terminal<int const &>::type>::type p1 = functor::make_expr<tag::unary_plus>()(boost::cref(1)); // DANGEROUS
- unary_plus<terminal<int &>::type>::type p2 = functor::make_expr<tag::unary_plus>()(boost::ref(i));
+ unary_plus<terminal<int const &>::type>::type p1 = functional::make_expr<tag::unary_plus>()(boost::cref(1)); // DANGEROUS
+ unary_plus<terminal<int &>::type>::type p2 = functional::make_expr<tag::unary_plus>()(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functor::make_expr<tag::unary_plus, mydomain>()(boost::ref(i));
+ ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functional::make_expr<tag::unary_plus, mydomain>()(boost::ref(i));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
ewrap<plus<
ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
, ewrap<terminal<int>::type>
- >::type> p4 = functor::make_expr<tag::plus, mydomain>()(boost::ref(p3), 0);
+ >::type> p4 = functional::make_expr<tag::plus, mydomain>()(boost::ref(p3), 0);
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -133,19 +134,19 @@
void test_unpack_expr_functional()
{
int i = 42;
- terminal<int>::type t1 = functor::unpack_expr<tag::terminal>()(fusion::make_tuple(1));
- terminal<int &>::type t2 = functor::unpack_expr<tag::terminal>()(fusion::make_tuple(boost::ref(i)));
- unary_plus<terminal<int>::type>::type p1 = functor::unpack_expr<tag::unary_plus>()(fusion::make_tuple(1));
- unary_plus<terminal<int &>::type>::type p2 = functor::unpack_expr<tag::unary_plus>()(fusion::make_tuple(boost::ref(i)));
+ terminal<int>::type t1 = functional::unpack_expr<tag::terminal>()(fusion::make_tuple(1));
+ terminal<int &>::type t2 = functional::unpack_expr<tag::terminal>()(fusion::make_tuple(boost::ref(i)));
+ unary_plus<terminal<int>::type>::type p1 = functional::unpack_expr<tag::unary_plus>()(fusion::make_tuple(1));
+ unary_plus<terminal<int &>::type>::type p2 = functional::unpack_expr<tag::unary_plus>()(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p2)), 42);
- ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functor::unpack_expr<tag::unary_plus, mydomain>()(fusion::make_tuple(boost::ref(i)));
+ ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> p3 = functional::unpack_expr<tag::unary_plus, mydomain>()(fusion::make_tuple(boost::ref(i)));
BOOST_CHECK_EQUAL(proto::value(proto::child(p3)), 42);
ewrap<plus<
ewrap<unary_plus<ewrap<terminal<int &>::type> >::type> &
, ewrap<terminal<int>::type>
- >::type> p4 = functor::unpack_expr<tag::plus>()(fusion::make_tuple(boost::ref(p3), 0));
+ >::type> p4 = functional::unpack_expr<tag::plus>()(fusion::make_tuple(boost::ref(p3), 0));
BOOST_CHECK_EQUAL(proto::value(proto::child(proto::left(p4))), 42);
}
@@ -217,6 +218,70 @@
>::type t4 = Square()(as_expr(1) + 1);
}
+
+struct length_impl {};
+struct dot_impl {};
+
+terminal<length_impl>::type const length = {{}};
+terminal<dot_impl>::type const dot = {{}};
+
+// work around msvc bugs...
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+#define _byref(a) call<_byref(a)>
+#define _byval(a) call<_byval(a)>
+#define _child1(a) call<_child1(a)>
+#define _make_terminal(a) call<_make_terminal(a)>
+#define _make_function(a,b,c) call<_make_function(a,b,c)>
+#define dot_impl() make<dot_impl()>
+#endif
+
+// convert length(a) < length(b) to dot(a,a) < dot(b,b)
+struct Convert
+ : when<
+ less<
+ function<terminal<length_impl>, _>
+ , function<terminal<length_impl>, _>
+ >
+ , _make_less(
+ _make_function(
+ _make_terminal(dot_impl())
+ , _child1(_child0)
+ , _child1(_child0)
+ )
+ , _make_function(
+ _make_terminal(dot_impl())
+ , _child1(_child1)
+ , _child1(_child1)
+ )
+ )
+ >
+{};
+
+template<typename Expr>
+void test_make_expr_transform2_test(Expr const &expr)
+{
+ void const *addr1 = boost::addressof(proto::child_c<1>(proto::child_c<0>(expr)));
+ void const *addr2 = boost::addressof(proto::child_c<1>(proto::child_c<0>(Convert()(expr))));
+ BOOST_CHECK_EQUAL(addr1, addr2);
+
+ BOOST_CHECK_EQUAL(1, proto::value(proto::child_c<1>(proto::child_c<0>(expr))));
+ BOOST_CHECK_EQUAL(1, proto::value(proto::child_c<1>(proto::child_c<0>(Convert()(expr)))));
+}
+
+void test_make_expr_transform2()
+{
+ test_make_expr_transform2_test(length(1) < length(2));
+}
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+#undef _byref
+#undef _byval
+#undef _child1
+#undef _make_terminal
+#undef _make_function
+#undef dot_impl
+#endif
+
using namespace unit_test;
///////////////////////////////////////////////////////////////////////////////
// init_unit_test_suite
@@ -232,6 +297,7 @@
test->add(BOOST_TEST_CASE(&test_unpack_expr));
test->add(BOOST_TEST_CASE(&test_unpack_expr_functional));
test->add(BOOST_TEST_CASE(&test_make_expr_transform));
+ test->add(BOOST_TEST_CASE(&test_make_expr_transform2));
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