|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67155 - in branches/release: . boost boost/algorithm/string boost/archive boost/bimap boost/config boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/io boost/iostreams boost/math boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/proto boost/proto/functional boost/proto/functional/fusion boost/proto/functional/std boost/proto/transform boost/python boost/range boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/typeof boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/algorithm/string libs/array/doc libs/array/test libs/bimap libs/config libs/date_time libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/math libs/math/doc libs/math/doc/sf_and_dist libs/mpi/build libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/proto/doc libs/proto/doc/reference libs/proto/doc/reference/functional libs/proto/doc/reference/functional/fusion libs/proto/doc/reference/functional/std libs/proto/doc/reference/transform libs/proto/test libs/python libs/range libs/regex libs/serialization libs/serialization/doc libs/serialization/example libs/serialization/src libs/serialization/test libs/serialization/vc7ide libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/type_traits/doc libs/typeof/doc libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more more/getting_started status tools tools/bcp tools/boostbook tools/build/v2 tools/inspect tools/quickbook tools/regression tools/regression/src tools/release tools/wave
From: eric_at_[hidden]
Date: 2010-12-10 23:33:26
Author: eric_niebler
Date: 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
New Revision: 67155
URL: http://svn.boost.org/trac/boost/changeset/67155
Log:
Merged revisions 66150,66196-66200,66805,66836,66990,67053,67122,67154 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r66150 | eric_niebler | 2010-10-22 17:07:23 -0400 (Fri, 22 Oct 2010) | 1 line
add nested which typedef for matches with switch_ and if_ for Phoenix-style extensible grammars
........
r66196 | eric_niebler | 2010-10-25 19:55:22 -0400 (Mon, 25 Oct 2010) | 1 line
add when<T, external> to allow transforms to be specified with the Data parameter
........
r66197 | eric_niebler | 2010-10-25 19:57:16 -0400 (Mon, 25 Oct 2010) | 1 line
optimize boost::tr1_result_of for default_domain and default_generator
........
r66198 | eric_niebler | 2010-10-25 19:58:26 -0400 (Mon, 25 Oct 2010) | 1 line
clean-up
........
r66199 | eric_niebler | 2010-10-25 20:53:39 -0400 (Mon, 25 Oct 2010) | 1 line
s/external/external_transform/ and s/action_map/external_transforms/
........
r66200 | eric_niebler | 2010-10-26 01:42:13 -0400 (Tue, 26 Oct 2010) | 1 line
small tweak, add docs for external transforms
........
r66805 | eric_niebler | 2010-11-28 00:04:50 -0500 (Sun, 28 Nov 2010) | 1 line
fix long-standing bug in proto::make, add more callable wrappers for std utility and fusion algos, reorg and clean-up
........
r66836 | eric_niebler | 2010-11-28 22:58:02 -0500 (Sun, 28 Nov 2010) | 1 line
pop_front and reverse are not in core, add docs for new callables
........
r66990 | eric_niebler | 2010-12-03 17:10:14 -0500 (Fri, 03 Dec 2010) | 1 line
ah! the REAL fix for the long-standing proto::make bug
........
r67053 | eric_niebler | 2010-12-05 20:01:47 -0500 (Sun, 05 Dec 2010) | 1 line
revert to old slightly broken make behavior, instead of the new and very broken behavior (sigh)
........
r67122 | eric_niebler | 2010-12-08 23:08:40 -0500 (Wed, 08 Dec 2010) | 1 line
proto::matches preserves domain-specific expression wrappers
........
r67154 | eric_niebler | 2010-12-10 23:08:58 -0500 (Fri, 10 Dec 2010) | 1 line
doc tweak
........
Added:
branches/release/boost/proto/functional/
- copied from r66805, /trunk/boost/proto/functional/
branches/release/boost/proto/functional.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional.hpp
branches/release/boost/proto/functional/fusion/
- copied from r66805, /trunk/boost/proto/functional/fusion/
branches/release/boost/proto/functional/fusion.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion.hpp
branches/release/boost/proto/functional/fusion/pop_back.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion/pop_back.hpp
branches/release/boost/proto/functional/fusion/pop_front.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion/pop_front.hpp
branches/release/boost/proto/functional/fusion/push_back.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion/push_back.hpp
branches/release/boost/proto/functional/fusion/push_front.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion/push_front.hpp
branches/release/boost/proto/functional/fusion/reverse.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/fusion/reverse.hpp
branches/release/boost/proto/functional/std/
- copied from r66805, /trunk/boost/proto/functional/std/
branches/release/boost/proto/functional/std.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/std.hpp
branches/release/boost/proto/functional/std/utility.hpp
- copied unchanged from r66805, /trunk/boost/proto/functional/std/utility.hpp
branches/release/libs/proto/doc/reference/functional/
- copied from r66836, /trunk/libs/proto/doc/reference/functional/
branches/release/libs/proto/doc/reference/functional.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional.xml
branches/release/libs/proto/doc/reference/functional/fusion/
- copied from r66836, /trunk/libs/proto/doc/reference/functional/fusion/
branches/release/libs/proto/doc/reference/functional/fusion.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion.xml
branches/release/libs/proto/doc/reference/functional/fusion/pop_back.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion/pop_back.xml
branches/release/libs/proto/doc/reference/functional/fusion/pop_front.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion/pop_front.xml
branches/release/libs/proto/doc/reference/functional/fusion/push_back.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion/push_back.xml
branches/release/libs/proto/doc/reference/functional/fusion/push_front.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion/push_front.xml
branches/release/libs/proto/doc/reference/functional/fusion/reverse.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/fusion/reverse.xml
branches/release/libs/proto/doc/reference/functional/std/
- copied from r66836, /trunk/libs/proto/doc/reference/functional/std/
branches/release/libs/proto/doc/reference/functional/std.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/std.xml
branches/release/libs/proto/doc/reference/functional/std/utility.xml
- copied unchanged from r66836, /trunk/libs/proto/doc/reference/functional/std/utility.xml
Properties modified:
branches/release/ (props changed)
branches/release/INSTALL (props changed)
branches/release/Jamroot (props changed)
branches/release/LICENSE_1_0.txt (props changed)
branches/release/boost/ (props changed)
branches/release/boost-build.jam (props changed)
branches/release/boost.css (props changed)
branches/release/boost.png (props changed)
branches/release/boost/algorithm/string/ (props changed)
branches/release/boost/archive/ (props changed)
branches/release/boost/array.hpp (props changed)
branches/release/boost/bimap/ (props changed)
branches/release/boost/config/ (props changed)
branches/release/boost/config.hpp (props changed)
branches/release/boost/detail/ (props changed)
branches/release/boost/detail/endian.hpp (props changed)
branches/release/boost/filesystem/ (props changed)
branches/release/boost/filesystem.hpp (props changed)
branches/release/boost/functional/hash/ (props changed)
branches/release/boost/fusion/ (props changed)
branches/release/boost/gil/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/integer/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/io/ (props changed)
branches/release/boost/iostreams/ (props changed)
branches/release/boost/math/ (props changed)
branches/release/boost/math_fwd.hpp (props changed)
branches/release/boost/msm/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/numeric/ublas/functional.hpp (props changed)
branches/release/boost/program_options/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/python/ (props changed)
branches/release/boost/range/ (props changed)
branches/release/boost/regex/ (props changed)
branches/release/boost/serialization/ (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2/ (props changed)
branches/release/boost/signals2.hpp (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/statechart/ (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/thread/ (props changed)
branches/release/boost/thread.hpp (props changed)
branches/release/boost/token_functions.hpp (props changed)
branches/release/boost/tr1/ (props changed)
branches/release/boost/type_traits/ (props changed)
branches/release/boost/typeof/message.hpp (props changed)
branches/release/boost/typeof/register_functions.hpp (props changed)
branches/release/boost/typeof/register_functions_iterate.hpp (props changed)
branches/release/boost/typeof/typeof.hpp (props changed)
branches/release/boost/typeof/unsupported.hpp (props changed)
branches/release/boost/unordered/ (props changed)
branches/release/boost/utility/ (props changed)
branches/release/boost/utility/value_init.hpp (props changed)
branches/release/boost/uuid/ (props changed)
branches/release/boost/variant/ (props changed)
branches/release/boost/version.hpp (props changed)
branches/release/boost/wave/ (props changed)
branches/release/bootstrap.bat (props changed)
branches/release/bootstrap.sh (props changed)
branches/release/doc/ (props changed)
branches/release/index.htm (props changed)
branches/release/index.html (props changed)
branches/release/libs/ (props changed)
branches/release/libs/algorithm/string/ (props changed)
branches/release/libs/array/doc/array.xml (props changed)
branches/release/libs/array/test/array0.cpp (props changed)
branches/release/libs/array/test/array2.cpp (props changed)
branches/release/libs/bimap/ (props changed)
branches/release/libs/config/ (props changed)
branches/release/libs/date_time/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/functional/hash/ (props changed)
branches/release/libs/fusion/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/integer/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/iostreams/ (props changed)
branches/release/libs/libraries.htm (props changed)
branches/release/libs/maintainers.txt (props changed)
branches/release/libs/math/ (props changed)
branches/release/libs/math/doc/ (props changed)
branches/release/libs/math/doc/sf_and_dist/ (props changed)
branches/release/libs/mpi/build/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/msm/ (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/program_options/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/python/ (props changed)
branches/release/libs/range/ (props changed)
branches/release/libs/regex/ (props changed)
branches/release/libs/serialization/ (props changed)
branches/release/libs/serialization/doc/ (props changed)
branches/release/libs/serialization/example/ (props changed)
branches/release/libs/serialization/src/ (props changed)
branches/release/libs/serialization/test/test_diamond_complex.cpp (props changed)
branches/release/libs/serialization/vc7ide/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/signals2/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/statechart/ (props changed)
branches/release/libs/static_assert/ (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/thread/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/tr1/ (props changed)
branches/release/libs/type_traits/ (props changed)
branches/release/libs/type_traits/doc/ (props changed)
branches/release/libs/typeof/doc/typeof.qbk (props changed)
branches/release/libs/unordered/ (props changed)
branches/release/libs/utility/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
branches/release/libs/utility/value_init.htm (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/uuid/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/more/ (props changed)
branches/release/more/getting_started/ (props changed)
branches/release/rst.css (props changed)
branches/release/status/ (props changed)
branches/release/status/Jamfile.v2 (props changed)
branches/release/status/explicit-failures-markup.xml (props changed)
branches/release/tools/ (props changed)
branches/release/tools/bcp/ (props changed)
branches/release/tools/boostbook/ (props changed)
branches/release/tools/build/v2/ (props changed)
branches/release/tools/inspect/ (props changed)
branches/release/tools/quickbook/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/regression/src/library_status.cpp (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
Text files modified:
branches/release/boost/proto/domain.hpp | 22 +++
branches/release/boost/proto/extends.hpp | 16 +-
branches/release/boost/proto/fusion.hpp | 119 +-------------------
branches/release/boost/proto/generate.hpp | 18 ++
branches/release/boost/proto/make_expr.hpp | 67 -----------
branches/release/boost/proto/matches.hpp | 229 ++++++++++++++++++++++-----------------
branches/release/boost/proto/proto.hpp | 1
branches/release/boost/proto/proto_fwd.hpp | 29 +++-
branches/release/boost/proto/traits.hpp | 44 +++++-
branches/release/boost/proto/transform/default.hpp | 2
branches/release/boost/proto/transform/fold.hpp | 1
branches/release/boost/proto/transform/fold_tree.hpp | 1
branches/release/boost/proto/transform/make.hpp | 34 ++++-
branches/release/boost/proto/transform/when.hpp | 95 ++++++++++++++++
branches/release/libs/proto/doc/reference.xml | 54 +++++++++
branches/release/libs/proto/doc/reference/fusion.xml | 138 ------------------------
branches/release/libs/proto/doc/reference/proto_fwd.xml | 18 +++
branches/release/libs/proto/doc/reference/traits.xml | 46 ++++++++
branches/release/libs/proto/doc/reference/transform/call.xml | 104 ++++++++++--------
branches/release/libs/proto/doc/reference/transform/make.xml | 16 ++
branches/release/libs/proto/doc/reference/transform/when.xml | 137 +++++++++++++++++++++++
branches/release/libs/proto/test/examples.cpp | 1
branches/release/libs/proto/test/matches.cpp | 19 +++
23 files changed, 702 insertions(+), 509 deletions(-)
Modified: branches/release/boost/proto/domain.hpp
==============================================================================
--- branches/release/boost/proto/domain.hpp (original)
+++ branches/release/boost/proto/domain.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -292,6 +292,28 @@
typedef typename domain_of<T>::type type;
};
+ /// A metafunction that returns \c mpl::true_
+ /// if the type \c SubDomain is a sub-domain of
+ /// \c SuperDomain; \c mpl::false_ otherwise.
+ template<typename SubDomain, typename SuperDomain>
+ struct is_sub_domain_of
+ : is_sub_domain_of<typename SubDomain::proto_super_domain, SuperDomain>
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<typename SuperDomain>
+ struct is_sub_domain_of<proto::no_super_domain, SuperDomain>
+ : mpl::false_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<typename SuperDomain>
+ struct is_sub_domain_of<SuperDomain, SuperDomain>
+ : mpl::true_
+ {};
+
}}
#endif
Modified: branches/release/boost/proto/extends.hpp
==============================================================================
--- branches/release/boost/proto/extends.hpp (original)
+++ branches/release/boost/proto/extends.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -204,7 +204,7 @@
BOOST_PROTO_DISABLE_MSVC_C4522 \
Typename() boost::tr1_result_of< \
Typename() This::proto_generator( \
- Typename() boost::proto::base_expr< \
+ Typename() boost::proto::base_expr< \
Typename() This::proto_domain \
, boost::proto::tag::assign \
, boost::proto::list2< \
@@ -217,7 +217,7 @@
operator =(This Const() &a) \
{ \
typedef \
- Typename() boost::proto::base_expr< \
+ Typename() boost::proto::base_expr< \
Typename() This::proto_domain \
, boost::proto::tag::assign \
, boost::proto::list2< \
@@ -253,7 +253,7 @@
template<typename A> \
typename boost::tr1_result_of< \
proto_generator( \
- typename boost::proto::base_expr< \
+ typename boost::proto::base_expr< \
proto_domain \
, boost::proto::tag::assign \
, boost::proto::list2< \
@@ -266,7 +266,7 @@
operator =(A ThatConst() &a) ThisConst() \
{ \
typedef \
- typename boost::proto::base_expr< \
+ typename boost::proto::base_expr< \
proto_domain \
, boost::proto::tag::assign \
, boost::proto::list2< \
@@ -274,12 +274,12 @@
, typename boost::proto::result_of::as_child<A ThatConst(), proto_domain>::type \
> \
>::type \
- that_type; \
+ that_type; \
that_type const that = { \
*static_cast<proto_derived_expr ThisConst() *>(this) \
, boost::proto::as_child<proto_domain>(a) \
}; \
- return proto_generator()(that); \
+ return proto_generator()(that); \
} \
/**/
@@ -319,7 +319,7 @@
template<typename A> \
typename boost::tr1_result_of< \
proto_generator( \
- typename boost::proto::base_expr< \
+ typename boost::proto::base_expr< \
proto_domain \
, boost::proto::tag::subscript \
, boost::proto::list2< \
@@ -332,7 +332,7 @@
operator [](A ThatConst() &a) ThisConst() \
{ \
typedef \
- typename boost::proto::base_expr< \
+ typename boost::proto::base_expr< \
proto_domain \
, boost::proto::tag::subscript \
, boost::proto::list2< \
Modified: branches/release/boost/proto/fusion.hpp
==============================================================================
--- branches/release/boost/proto/fusion.hpp (original)
+++ branches/release/boost/proto/fusion.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -18,8 +18,6 @@
#include <boost/fusion/include/category_of.hpp>
#include <boost/fusion/include/iterator_base.hpp>
#include <boost/fusion/include/intrinsic.hpp>
-#include <boost/fusion/include/pop_front.hpp>
-#include <boost/fusion/include/reverse.hpp>
#include <boost/fusion/include/single_view.hpp>
#include <boost/fusion/include/transform_view.hpp>
#include <boost/fusion/support/ext_/is_segmented.hpp>
@@ -39,10 +37,8 @@
namespace boost { namespace proto
{
-
namespace detail
{
-
template<typename Expr, long Pos>
struct expr_iterator
: fusion::iterator_base<expr_iterator<Expr, Pos> >
@@ -171,92 +167,6 @@
return proto::detail::flat_view<Expr const>(e);
}
};
-
- /// \brief A PolymorphicFunctionObject type that invokes the
- /// \c fusion::pop_front() algorithm on its argument.
- ///
- /// A PolymorphicFunctionObject type that invokes the
- /// \c fusion::pop_front() algorithm on its argument. This is
- /// useful for defining a CallableTransform like \c pop_front(_)
- /// which removes the first child from a Proto expression node.
- /// Such a transform might be used as the first argument to the
- /// \c proto::fold\<\> transform; that is, fold all but
- /// the first child.
- struct pop_front
- {
- BOOST_PROTO_CALLABLE()
-
- template<typename Sig>
- struct result;
-
- template<typename This, typename Expr>
- struct result<This(Expr)>
- : result<This(Expr const &)>
- {};
-
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- : fusion::result_of::pop_front<Expr>
- {};
-
- template<typename Expr>
- typename fusion::result_of::pop_front<Expr>::type
- operator ()(Expr &e) const
- {
- // Work around a const-correctness issue in Fusion
- typedef typename fusion::result_of::pop_front<Expr>::type result_type;
- return result_type(fusion::next(fusion::begin(e)), fusion::end(e));
- }
-
- template<typename Expr>
- typename fusion::result_of::pop_front<Expr const>::type
- operator ()(Expr const &e) const
- {
- return fusion::pop_front(e);
- }
- };
-
- /// \brief A PolymorphicFunctionObject type that invokes the
- /// \c fusion::reverse() algorithm on its argument.
- ///
- /// A PolymorphicFunctionObject type that invokes the
- /// \c fusion::reverse() algorithm on its argument. This is
- /// useful for defining a CallableTransform like \c reverse(_)
- /// which reverses the order of the children of a Proto
- /// expression node.
- struct reverse
- {
- BOOST_PROTO_CALLABLE()
-
- template<typename Sig>
- struct result;
-
- template<typename This, typename Expr>
- struct result<This(Expr)>
- : result<This(Expr const &)>
- {};
-
- template<typename This, typename Expr>
- struct result<This(Expr &)>
- : fusion::result_of::reverse<Expr>
- {};
-
- template<typename Expr>
- typename fusion::result_of::reverse<Expr>::type
- operator ()(Expr &e) const
- {
- // Work around a const-correctness issue in Fusion
- typedef typename fusion::result_of::reverse<Expr>::type result_type;
- return result_type(e);
- }
-
- template<typename Expr>
- typename fusion::result_of::reverse<Expr const>::type
- operator ()(Expr const &e) const
- {
- return fusion::reverse(e);
- }
- };
}
/// \brief A function that returns a "flattened"
@@ -288,29 +198,9 @@
/// INTERNAL ONLY
///
- template<>
- struct is_callable<functional::flatten>
- : mpl::true_
- {};
-
- /// INTERNAL ONLY
- ///
- template<>
- struct is_callable<functional::pop_front>
- : mpl::true_
- {};
-
- /// INTERNAL ONLY
- ///
- template<>
- struct is_callable<functional::reverse>
- : mpl::true_
- {};
-
- /// INTERNAL ONLY
- ///
template<typename Context>
struct eval_fun
+ : proto::callable
{
explicit eval_fun(Context &ctx)
: ctx_(ctx)
@@ -346,6 +236,13 @@
private:
Context &ctx_;
};
+
+ /// INTERNAL ONLY
+ ///
+ template<typename Context>
+ struct is_callable<eval_fun<Context> >
+ : mpl::true_
+ {};
}}
namespace boost { namespace fusion
Modified: branches/release/boost/proto/generate.hpp
==============================================================================
--- branches/release/boost/proto/generate.hpp (original)
+++ branches/release/boost/proto/generate.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -12,6 +12,7 @@
#define BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007
#include <boost/config.hpp>
+ #include <boost/version.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
@@ -369,7 +370,8 @@
}}
- // Specialization of boost::result_of to eliminate some unnecessary template instantiations
+ // Specializations of boost::result_of and boost::tr1_result_of to eliminate
+ // some unnecessary template instantiations
namespace boost
{
template<typename Expr>
@@ -383,6 +385,20 @@
{
typedef Expr type;
};
+
+ #if BOOST_VERSION >= 104400
+ template<typename Expr>
+ struct tr1_result_of<proto::default_domain(Expr)>
+ {
+ typedef Expr type;
+ };
+
+ template<typename Expr>
+ struct tr1_result_of<proto::default_generator(Expr)>
+ {
+ typedef Expr type;
+ };
+ #endif
}
#endif // BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007
Modified: branches/release/boost/proto/make_expr.hpp
==============================================================================
--- branches/release/boost/proto/make_expr.hpp (original)
+++ branches/release/boost/proto/make_expr.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -53,19 +53,6 @@
# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
#endif
- namespace boost
- {
- /// INTERNAL ONLY
- ///
- namespace fusion
- {
- /// INTERNAL ONLY
- ///
- template<typename Function>
- class unfused_generic;
- }
- }
-
namespace boost { namespace proto
{
/// INTERNAL ONLY
@@ -481,8 +468,7 @@
BOOST_PROTO_CALLABLE()
template<typename Sig>
- struct result
- {};
+ struct result;
template<typename This, typename Sequence>
struct result<This(Sequence)>
@@ -514,50 +500,6 @@
}
};
- /// INTERNAL ONLY
- ///
- template<typename Tag, typename Domain>
- struct unfused_expr_fun
- {
- BOOST_PROTO_CALLABLE()
-
- template<typename Sig>
- struct result;
-
- template<typename This, typename Sequence>
- struct result<This(Sequence)>
- {
- typedef
- typename result_of::unpack_expr<
- Tag
- , Domain
- , typename remove_reference<Sequence>::type
- >::type
- type;
- };
-
- template<typename Sequence>
- typename proto::result_of::unpack_expr<Tag, Domain, Sequence const>::type const
- operator ()(Sequence const &sequence) const
- {
- return proto::detail::unpack_expr_<
- Tag
- , Domain
- , Sequence const
- , fusion::result_of::size<Sequence>::type::value
- >::call(sequence);
- }
- };
-
- /// INTERNAL ONLY
- ///
- template<typename Tag, typename Domain>
- struct unfused_expr
- : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> >
- {
- BOOST_PROTO_CALLABLE()
- };
-
} // namespace functional
/// \brief Construct an expression of the requested tag type
@@ -693,13 +635,6 @@
: mpl::true_
{};
- /// INTERNAL ONLY
- ///
- template<typename Tag, typename Domain>
- struct is_callable<functional::unfused_expr<Tag, Domain> >
- : mpl::true_
- {};
-
}}
#ifdef _MSC_VER
Modified: branches/release/boost/proto/matches.hpp
==============================================================================
--- branches/release/boost/proto/matches.hpp (original)
+++ branches/release/boost/proto/matches.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -67,7 +67,7 @@
namespace detail
{
- template<typename Expr, typename Grammar>
+ template<typename Expr, typename BasicExpr, typename Grammar>
struct matches_;
template<bool B, typename Pred>
@@ -138,24 +138,26 @@
struct vararg_matches_impl;
// vararg_matches
- template<typename Args1, typename Args2, typename Back, bool Can, bool Zero, typename Void = void>
+ template<typename Expr, typename Args1, typename Args2, typename Back, bool Can, bool Zero, typename Void = void>
struct vararg_matches
: mpl::false_
{};
- template<typename Args1, typename Args2, typename Back>
- struct vararg_matches<Args1, Args2, Back, true, true, typename Back::proto_is_vararg_>
+ template<typename Expr, typename Args1, typename Args2, typename Back>
+ struct vararg_matches<Expr, Args1, Args2, Back, true, true, typename Back::proto_is_vararg_>
: matches_<
- proto::basic_expr<ignore, Args1, Args1::arity>
+ Expr
+ , proto::basic_expr<ignore, Args1, Args1::arity>
, proto::basic_expr<ignore, Args2, Args1::arity>
>
{};
- template<typename Args1, typename Args2, typename Back>
- struct vararg_matches<Args1, Args2, Back, true, false, typename Back::proto_is_vararg_>
+ template<typename Expr, typename Args1, typename Args2, typename Back>
+ struct vararg_matches<Expr, Args1, Args2, Back, true, false, typename Back::proto_is_vararg_>
: and_2<
matches_<
- proto::basic_expr<ignore, Args1, Args2::arity>
+ Expr
+ , proto::basic_expr<ignore, Args1, Args2::arity>
, proto::basic_expr<ignore, Args2, Args2::arity>
>::value
, vararg_matches_impl<Args1, typename Back::proto_grammar, Args2::arity + 1, Args1::arity>
@@ -297,66 +299,70 @@
{};
// matches_
- template<typename Expr, typename Grammar>
+ template<typename Expr, typename BasicExpr, typename Grammar>
struct matches_
: mpl::false_
{};
- template<typename Expr>
- struct matches_< Expr, proto::_ >
+ template<typename Expr, typename BasicExpr>
+ struct matches_< Expr, BasicExpr, proto::_ >
: mpl::true_
{};
- template<typename Tag, typename Args1, long N1, typename Args2, long N2>
- struct matches_< proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<Tag, Args2, N2> >
- : vararg_matches< Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
+ template<typename Expr, typename Tag, typename Args1, long N1, typename Args2, long N2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<Tag, Args2, N2> >
+ : vararg_matches< Expr, Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
{};
- template<typename Tag, typename Args1, long N1, typename Args2, long N2>
- struct matches_< proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<proto::_, Args2, N2> >
- : vararg_matches< Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
+ template<typename Expr, typename Tag, typename Args1, long N1, typename Args2, long N2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, N1>, proto::basic_expr<proto::_, Args2, N2> >
+ : vararg_matches< Expr, Args1, Args2, typename Args2::back_, (N1+2 > N2), (N2 > N1) >
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<Tag, Args2, 0> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<Tag, Args2, 0> >
: terminal_matches<typename Args1::child0, typename Args2::child0>
{};
- template<typename Tag, typename Args1, typename Args2, long N2>
- struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, N2> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2, long N2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, N2> >
: mpl::false_
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, 0> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, 0>, proto::basic_expr<proto::_, Args2, 0> >
: terminal_matches<typename Args1::child0, typename Args2::child0>
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<Tag, Args2, 1> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<Tag, Args2, 1> >
: matches_<
- typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
- , typename Args2::child0::proto_grammar
- >
+ typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr
+ , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
+ , typename Args2::child0::proto_grammar
+ >
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<proto::_, Args2, 1> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, 1>, proto::basic_expr<proto::_, Args2, 1> >
: matches_<
- typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
- , typename Args2::child0::proto_grammar
- >
+ typename detail::expr_traits<typename Args1::child0>::value_type::proto_derived_expr
+ , typename detail::expr_traits<typename Args1::child0>::value_type::proto_grammar
+ , typename Args2::child0::proto_grammar
+ >
{};
#define BOOST_PROTO_MATCHES_N_FUN(Z, N, DATA) \
matches_< \
- typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_grammar\
+ typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_derived_expr \
+ , typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_grammar \
, typename Args2::BOOST_PP_CAT(child, N)::proto_grammar \
>
#define BOOST_PROTO_DEFINE_MATCHES(Z, N, DATA) \
matches_< \
Expr \
+ , BasicExpr \
, typename BOOST_PP_CAT(G, N)::proto_grammar \
>
@@ -381,66 +387,70 @@
#undef BOOST_PROTO_DEFINE_LAMBDA_MATCHES
// handle proto::if_
- template<typename Tag, typename Args, long Arity, typename If, typename Then, typename Else>
- struct matches_<proto::basic_expr<Tag, Args, Arity>, proto::if_<If, Then, Else> >
+ template<typename Expr, typename Tag, typename Args, long Arity, typename If, typename Then, typename Else>
+ struct matches_<Expr, proto::basic_expr<Tag, Args, Arity>, proto::if_<If, Then, Else> >
: mpl::eval_if_c<
remove_reference<
- typename when<_, If>::
- template impl<proto::expr<Tag, Args, Arity>, int, int>::result_type
+ typename when<_, If>::template impl<Expr, int, int>::result_type
>::type::value
- , matches_<proto::basic_expr<Tag, Args, Arity>, typename Then::proto_grammar>
- , matches_<proto::basic_expr<Tag, Args, Arity>, typename Else::proto_grammar>
+ , matches_<Expr, proto::basic_expr<Tag, Args, Arity>, typename Then::proto_grammar>
+ , matches_<Expr, proto::basic_expr<Tag, Args, Arity>, typename Else::proto_grammar>
>::type
- {};
-
- template<typename Tag, typename Args, long Arity, typename If>
- struct matches_<proto::basic_expr<Tag, Args, Arity>, proto::if_<If> >
- : detail::uncvref<
- typename when<_, If>::
- template impl<proto::expr<Tag, Args, Arity>, int, int>::result_type
- >::type
- {};
+ {
+ typedef
+ typename mpl::if_c<
+ remove_reference<
+ typename when<_, If>::template impl<Expr, int, int>::result_type
+ >::type::value
+ , Then
+ , Else
+ >::type
+ which;
+ };
// handle degenerate cases of proto::or_
- template<typename Expr>
- struct matches_<Expr, or_<> >
+ template<typename Expr, typename BasicExpr>
+ struct matches_<Expr, BasicExpr, or_<> >
: mpl::false_
{
typedef not_<_> which;
};
- template<typename Expr, typename G0>
- struct matches_<Expr, or_<G0> >
- : matches_<Expr, typename G0::proto_grammar>
+ template<typename Expr, typename BasicExpr, typename G0>
+ struct matches_<Expr, BasicExpr, or_<G0> >
+ : matches_<Expr, BasicExpr, typename G0::proto_grammar>
{
typedef G0 which;
};
// handle degenerate cases of proto::and_
- template<typename Expr>
- struct matches_<Expr, and_<> >
+ template<typename Expr, typename BasicExpr>
+ struct matches_<Expr, BasicExpr, and_<> >
: mpl::true_
{};
- template<typename Expr, typename G0>
- struct matches_<Expr, and_<G0> >
- : matches_<Expr, typename G0::proto_grammar>
+ template<typename Expr, typename BasicExpr, typename G0>
+ struct matches_<Expr, BasicExpr, and_<G0> >
+ : matches_<Expr, BasicExpr, typename G0::proto_grammar>
{};
// handle proto::not_
- template<typename Expr, typename Grammar>
- struct matches_<Expr, not_<Grammar> >
- : mpl::not_<matches_<Expr, typename Grammar::proto_grammar> >
+ template<typename Expr, typename BasicExpr, typename Grammar>
+ struct matches_<Expr, BasicExpr, not_<Grammar> >
+ : mpl::not_<matches_<Expr, BasicExpr, typename Grammar::proto_grammar> >
{};
// handle proto::switch_
- template<typename Tag, typename Args, long Arity, typename Cases>
- struct matches_<proto::basic_expr<Tag, Args, Arity>, switch_<Cases> >
+ template<typename Expr, typename Tag, typename Args, long Arity, typename Cases>
+ struct matches_<Expr, proto::basic_expr<Tag, Args, Arity>, switch_<Cases> >
: matches_<
- proto::basic_expr<Tag, Args, Arity>
+ Expr
+ , proto::basic_expr<Tag, Args, Arity>
, typename Cases::template case_<Tag>::proto_grammar
>
- {};
+ {
+ typedef typename Cases::template case_<Tag> which;
+ };
}
/// \brief A Boolean metafunction that evaluates whether a given
@@ -508,7 +518,8 @@
template<typename Expr, typename Grammar>
struct matches
: detail::matches_<
- typename Expr::proto_grammar
+ typename Expr::proto_derived_expr
+ , typename Expr::proto_grammar
, typename Grammar::proto_grammar
>
{};
@@ -518,7 +529,8 @@
template<typename Expr, typename Grammar>
struct matches<Expr &, Grammar>
: detail::matches_<
- typename Expr::proto_grammar
+ typename Expr::proto_derived_expr
+ , typename Expr::proto_grammar
, typename Grammar::proto_grammar
>
{};
@@ -757,14 +769,20 @@
template<typename Expr, typename State, typename Data>
struct impl
- : detail::matches_<typename Expr::proto_grammar, or_>
- ::which::template impl<Expr, State, Data>
+ : detail::matches_<
+ typename Expr::proto_derived_expr
+ , typename Expr::proto_grammar
+ , or_
+ >::which::template impl<Expr, State, Data>
{};
template<typename Expr, typename State, typename Data>
struct impl<Expr &, State, Data>
- : detail::matches_<typename Expr::proto_grammar, or_>
- ::which::template impl<Expr &, State, Data>
+ : detail::matches_<
+ typename Expr::proto_derived_expr
+ , typename Expr::proto_grammar
+ , or_
+ >::which::template impl<Expr &, State, Data>
{};
};
@@ -785,7 +803,7 @@
template<typename Expr, typename State, typename Data>
struct impl
- : detail::_and_impl<and_, Expr, State, Data>
+ : detail::_and_impl<and_, Expr, State, Data>
{};
};
@@ -819,12 +837,12 @@
template<typename Expr, typename State, typename Data>
struct impl
- : Cases::template case_<typename Expr::proto_tag>::template impl<Expr, State, Data>
+ : Cases::template case_<typename Expr::proto_tag>::template impl<Expr, State, Data>
{};
template<typename Expr, typename State, typename Data>
struct impl<Expr &, State, Data>
- : Cases::template case_<typename Expr::proto_tag>::template impl<Expr &, State, Data>
+ : Cases::template case_<typename Expr::proto_tag>::template impl<Expr &, State, Data>
{};
};
@@ -920,6 +938,13 @@
: mpl::true_
{};
+ /// INTERNAL ONLY
+ ///
+ template<typename Cases>
+ struct is_callable<switch_<Cases> >
+ : mpl::true_
+ {};
+
}}
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -981,40 +1006,40 @@
#undef M0
};
- template<bool B, typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
+ template<bool B, typename Expr, typename BasicExpr, BOOST_PP_ENUM_PARAMS(N, typename G)>
struct BOOST_PP_CAT(or_, N)
#if 2 == N
- : mpl::bool_<matches_<Expr, typename G1::proto_grammar>::value>
+ : mpl::bool_<matches_<Expr, BasicExpr, typename G1::proto_grammar>::value>
{
typedef G1 which;
};
#else
: BOOST_PP_CAT(or_, BOOST_PP_DEC(N))<
- matches_<Expr, typename G1::proto_grammar>::value
- , Expr, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
+ matches_<Expr, BasicExpr, typename G1::proto_grammar>::value
+ , Expr, BasicExpr, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
>
{};
#endif
- template<typename Expr BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G)>
- struct BOOST_PP_CAT(or_, N)<true, Expr, BOOST_PP_ENUM_PARAMS(N, G)>
+ template<typename Expr, typename BasicExpr BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G)>
+ struct BOOST_PP_CAT(or_, N)<true, Expr, BasicExpr, BOOST_PP_ENUM_PARAMS(N, G)>
: mpl::true_
{
typedef G0 which;
};
// handle proto::or_
- template<typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
- struct matches_<Expr, proto::or_<BOOST_PP_ENUM_PARAMS(N, G)> >
+ template<typename Expr, typename BasicExpr BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G)>
+ struct matches_<Expr, BasicExpr, proto::or_<BOOST_PP_ENUM_PARAMS(N, G)> >
: BOOST_PP_CAT(or_, N)<
- matches_<Expr, typename G0::proto_grammar>::value,
- Expr, BOOST_PP_ENUM_PARAMS(N, G)
+ matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
+ Expr, BasicExpr BOOST_PP_ENUM_TRAILING_PARAMS(N, G)
>
{};
// handle proto::and_
- template<typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
- struct matches_<Expr, proto::and_<BOOST_PP_ENUM_PARAMS(N, G)> >
+ template<typename Expr, typename BasicExpr, BOOST_PP_ENUM_PARAMS(N, typename G)>
+ struct matches_<Expr, BasicExpr, proto::and_<BOOST_PP_ENUM_PARAMS(N, G)> >
: detail::BOOST_PP_CAT(and_, N)<
BOOST_PROTO_DEFINE_MATCHES(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFINE_MATCHES, ~)
@@ -1032,9 +1057,10 @@
struct vararg_matches_impl<Args, Back, N, To>
: and_2<
matches_<
- typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
- , Back
- >::value
+ typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_derived_expr
+ , typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
+ , Back
+ >::value
, vararg_matches_impl<Args, Back, N + 1, To>
>
{};
@@ -1042,9 +1068,10 @@
template<typename Args, typename Back>
struct vararg_matches_impl<Args, Back, N, N>
: matches_<
- typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
- , Back
- >
+ typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_derived_expr
+ , typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_grammar
+ , Back
+ >
{};
template<
@@ -1053,26 +1080,26 @@
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Grammar)
>
struct lambda_matches<
- T<BOOST_PP_ENUM_PARAMS(N, Expr)>
- , T<BOOST_PP_ENUM_PARAMS(N, Grammar)>
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)
- >
+ T<BOOST_PP_ENUM_PARAMS(N, Expr)>
+ , T<BOOST_PP_ENUM_PARAMS(N, Grammar)>
+ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)
+ >
: BOOST_PP_CAT(and_, N)<
BOOST_PROTO_DEFINE_LAMBDA_MATCHES(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFINE_LAMBDA_MATCHES, ~)
>
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, N>, proto::basic_expr<Tag, Args2, N> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, N>, proto::basic_expr<Tag, Args2, N> >
: BOOST_PP_CAT(and_, N)<
BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
>
{};
- template<typename Tag, typename Args1, typename Args2>
- struct matches_< proto::basic_expr<Tag, Args1, N>, proto::basic_expr<proto::_, Args2, N> >
+ template<typename Expr, typename Tag, typename Args1, typename Args2>
+ struct matches_< Expr, proto::basic_expr<Tag, Args1, N>, proto::basic_expr<proto::_, Args2, N> >
: BOOST_PP_CAT(and_, N)<
BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
Modified: branches/release/boost/proto/proto.hpp
==============================================================================
--- branches/release/boost/proto/proto.hpp (original)
+++ branches/release/boost/proto/proto.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -13,5 +13,6 @@
#include <boost/proto/debug.hpp>
#include <boost/proto/context.hpp>
#include <boost/proto/transform.hpp>
+#include <boost/proto/functional.hpp>
#endif
Modified: branches/release/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/release/boost/proto/proto_fwd.hpp (original)
+++ branches/release/boost/proto/proto_fwd.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -424,6 +424,9 @@
template<typename T, typename Void = void>
struct is_domain;
+ template<typename SubDomain, typename SuperDomain>
+ struct is_sub_domain_of;
+
template<typename Expr>
struct tag_of;
@@ -525,12 +528,6 @@
template<typename Tag, typename Domain = deduce_domain>
struct unpack_expr;
- template<typename Tag, typename Domain = deduce_domain>
- struct unfused_expr_fun;
-
- template<typename Tag, typename Domain = deduce_domain>
- struct unfused_expr;
-
typedef make_expr<tag::terminal> make_terminal;
typedef make_expr<tag::unary_plus> make_unary_plus;
typedef make_expr<tag::negate> make_negate;
@@ -578,12 +575,24 @@
typedef make_expr<tag::function> make_function;
struct flatten;
+ struct make_pair;
+ struct first;
+ struct second;
struct pop_front;
+ struct push_front;
+ struct pop_back;
+ struct push_back;
struct reverse;
}
typedef functional::flatten _flatten;
+ typedef functional::make_pair _make_pair;
+ typedef functional::first _first;
+ typedef functional::second _second;
typedef functional::pop_front _pop_front;
+ typedef functional::push_front _push_front;
+ typedef functional::pop_back _pop_back;
+ typedef functional::push_back _push_back;
typedef functional::reverse _reverse;
typedef functional::eval _eval;
struct _deep_copy;
@@ -638,10 +647,10 @@
struct is_callable;
template<typename T, typename Void = void>
- struct is_aggregate;
+ struct is_transform;
template<typename T, typename Void = void>
- struct is_transform;
+ struct is_aggregate;
#define BOOST_PROTO_UNEXPR() typedef int proto_is_expr_;
#define BOOST_PROTO_CALLABLE() typedef void proto_is_callable_;
@@ -653,7 +662,9 @@
BOOST_PROTO_CALLABLE()
};
- template<typename PrimitiveTransform, typename X = void>
+ struct external_transform;
+
+ template<typename PrimitiveTransform = void, typename X = void>
struct transform;
template<typename Grammar, typename Fun = Grammar>
Modified: branches/release/boost/proto/traits.hpp
==============================================================================
--- branches/release/boost/proto/traits.hpp (original)
+++ branches/release/boost/proto/traits.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -66,6 +66,7 @@
struct is_callable_
: is_callable2_<T>
{};
+
}
/// \brief Boolean metafunction which detects whether a type is
@@ -107,6 +108,13 @@
: mpl::false_
{};
+ /// INTERNAL ONLY
+ ///
+ template<typename PrimitiveTransform, typename X>
+ struct is_callable<proto::transform<PrimitiveTransform, X> >
+ : mpl::false_
+ {};
+
#if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
// work around GCC bug
template<typename Tag, typename Args, long N>
@@ -121,6 +129,31 @@
{};
#endif
+ /// \brief Boolean metafunction which detects whether a type is
+ /// a PrimitiveTransform type or not.
+ ///
+ /// <tt>is_transform\<\></tt> is used by the <tt>call\<\></tt> transform
+ /// to determine whether the function types <tt>R()</tt>, <tt>R(A1)</tt>,
+ /// and <tt>R(A1, A2)</tt> should be passed the expression, state and data
+ /// parameters (as needed).
+ ///
+ /// Unless specialized for a type \c T, <tt>is_transform\<T\>::value</tt>
+ /// is computed as follows:
+ ///
+ /// \li If \c T has a nested type \c proto_is_transform_ that is a typedef
+ /// for \c void, <tt>is_transform\<T\>::value</tt> is \c true. (Note: this is
+ /// the case for any type that derives from an instantiation of \c proto::transform.)
+ /// \li Otherwise, <tt>is_transform\<T\>::value</tt> is \c false.
+ template<typename T, typename Void /*= void*/>
+ struct is_transform
+ : mpl::false_
+ {};
+
+ template<typename T>
+ struct is_transform<T, typename T::proto_is_transform_>
+ : mpl::true_
+ {};
+
/// \brief A Boolean metafunction that indicates whether a type requires
/// aggregate initialization.
///
@@ -153,17 +186,6 @@
: mpl::true_
{};
- /// TODO document me!
- template<typename T, typename Void /* = void*/>
- struct is_transform
- : mpl::false_
- {};
-
- template<typename T>
- struct is_transform<T, typename T::proto_is_transform_>
- : mpl::true_
- {};
-
/// \brief A Boolean metafunction that indicates whether a given
/// type \c T is a Proto expression type.
///
Modified: branches/release/boost/proto/transform/default.hpp
==============================================================================
--- branches/release/boost/proto/transform/default.hpp (original)
+++ branches/release/boost/proto/transform/default.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -81,7 +81,7 @@
\
template<typename Grammar> \
struct default_case<Grammar, tag::TAG> \
- : when<unary_expr<tag::TAG, Grammar>, BOOST_PP_CAT(default_, TAG)<Grammar> > \
+ : when<unary_expr<tag::TAG, Grammar>, BOOST_PP_CAT(default_, TAG)<Grammar> > \
{}; \
/**/
Modified: branches/release/boost/proto/transform/fold.hpp
==============================================================================
--- branches/release/boost/proto/transform/fold.hpp (original)
+++ branches/release/boost/proto/transform/fold.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -19,6 +19,7 @@
#include <boost/fusion/include/fold.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/fusion.hpp>
+ #include <boost/proto/functional/fusion/reverse.hpp>
#include <boost/proto/traits.hpp>
#include <boost/proto/transform/call.hpp>
#include <boost/proto/transform/impl.hpp>
Modified: branches/release/boost/proto/transform/fold_tree.hpp
==============================================================================
--- branches/release/boost/proto/transform/fold_tree.hpp (original)
+++ branches/release/boost/proto/transform/fold_tree.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -176,6 +176,7 @@
struct is_callable<reverse_fold_tree<Sequence, State0, Fun> >
: mpl::true_
{};
+
}}
#endif
Modified: branches/release/boost/proto/transform/make.hpp
==============================================================================
--- branches/release/boost/proto/transform/make.hpp (original)
+++ branches/release/boost/proto/transform/make.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -61,13 +61,6 @@
{};
template<typename R, typename Expr, typename State, typename Data
- // BUGBUG this should be is_transform, but if R is a template instantiation
- // it will cause the template to be instantiated, whereas is_callable will not.
- , bool IsTransform = is_callable<R>::value
- >
- struct make_if_;
-
- template<typename R, typename Expr, typename State, typename Data
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<R>::value)
>
struct make_
@@ -76,6 +69,28 @@
typedef void not_applied_;
};
+ template<typename R, typename Expr, typename State, typename Data
+ , bool IsTransform = is_transform<R>::value
+ >
+ struct make_if2_
+ : make_<R, Expr, State, Data>
+ {};
+
+ template<typename R, typename Expr, typename State, typename Data>
+ struct make_if2_<R, Expr, State, Data, true>
+ : uncvref<typename R::template impl<Expr, State, Data>::result_type>
+ {};
+
+ template<typename R, typename Expr, typename State, typename Data
+ // HACKHACK This should really be is_transform; however, is_transform
+ // would have the unfortunate side-effect of instantiating R which is
+ // not acceptable in this context. Instead, we first check to see if
+ // R is callable, which will not instantiate R. If is_callable is true,
+ // it is safe to instantiate R to check if it is a transform.
+ , bool IsCallable = is_callable<R>::value
+ >
+ struct make_if_;
+
template<typename R, typename Expr, typename State, typename Data>
struct make_if_<R, Expr, State, Data, false>
: make_<R, Expr, State, Data>
@@ -99,10 +114,9 @@
};
#endif
- // TODO could optimize this if R is a transform
template<typename R, typename Expr, typename State, typename Data>
struct make_if_<R, Expr, State, Data, true>
- : uncvref<typename R::template impl<Expr, State, Data>::result_type>
+ : make_if2_<R, Expr, State, Data>
{};
template<typename Type, bool IsAggregate = is_aggregate<Type>::value>
@@ -272,6 +286,7 @@
struct is_callable<protect<PrimitiveTransform> >
: mpl::true_
{};
+
}}
#endif
@@ -397,7 +412,6 @@
{
/// \brief <tt>boost::result_of\<make\<Object\>(Expr, State, Data)\>::type</tt>
typedef typename detail::make_if_<Object, Expr, State, Data>::type result_type;
- //typedef typename detail::make_<Object, Expr, State, Data>::type result_type;
/// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
/// for each \c x in <tt>[0,N]</tt>.
Modified: branches/release/boost/proto/transform/when.hpp
==============================================================================
--- branches/release/boost/proto/transform/when.hpp (original)
+++ branches/release/boost/proto/transform/when.hpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -14,7 +14,9 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
+ #include <boost/mpl/at.hpp>
#include <boost/mpl/if.hpp>
+ #include <boost/mpl/map.hpp>
#include <boost/proto/proto_fwd.hpp>
#include <boost/proto/traits.hpp>
#include <boost/proto/transform/call.hpp>
@@ -55,6 +57,8 @@
struct when
: PrimitiveTransform
{
+ typedef Grammar first;
+ typedef PrimitiveTransform second;
typedef typename Grammar::proto_grammar proto_grammar;
};
@@ -97,9 +101,98 @@
: when<_, Fun>
{};
+ /// \brief This specialization uses the Data parameter as a collection
+ /// of transforms that can be indexed by the specified rule.
+ ///
+ /// Use <tt>when\<T, external_transform\></tt> in your code when you would like
+ /// to define a grammar once and use it to evaluate expressions with
+ /// many different sets of transforms. The transforms are found by
+ /// using the Data parameter as a map from rules to transforms.
+ ///
+ /// See \c action_map for an example.
+ template<typename Grammar>
+ struct when<Grammar, external_transform>
+ : proto::transform<when<Grammar, external_transform> >
+ {
+ typedef Grammar first;
+ typedef external_transform second;
+ typedef typename Grammar::proto_grammar proto_grammar;
+
+ template<typename Expr, typename State, typename Data>
+ struct impl
+ : Data::template when<Grammar>::template impl<Expr, State, Data>
+ {};
+
+ template<typename Expr, typename State, typename Data>
+ struct impl<Expr, State, Data &>
+ : Data::template when<Grammar>::template impl<Expr, State, Data &>
+ {};
+ };
+
+ /// \brief For defining a map of Rule/Transform pairs for use with
+ /// <tt>when\<T, external_transform\></tt> to make transforms external to the grammar
+ ///
+ /// The following code defines a grammar with a couple of external transforms.
+ /// It also defines an action_map that maps from rules to transforms. It then
+ /// passes that transforms map at the Data parameter to the grammar. In this way,
+ /// the behavior of the grammar can be modified post-hoc by passing a different
+ /// action_map.
+ ///
+ /// \code
+ /// struct int_terminal
+ /// : proto::terminal<int>
+ /// {};
+ ///
+ /// struct char_terminal
+ /// : proto::terminal<char>
+ /// {};
+ ///
+ /// struct my_grammar
+ /// : proto::or_<
+ /// proto::when< int_terminal, proto::external_transform >
+ /// , proto::when< char_terminal, proto::external_transform >
+ /// , proto::when<
+ /// proto::plus< my_grammar, my_grammar >
+ /// , proto::fold< _, int(), my_grammar >
+ /// >
+ /// >
+ /// {};
+ ///
+ /// struct my_transforms
+ /// : proto::external_transforms<
+ /// proto::when<int_terminal, print(proto::_value)>
+ /// , proto::when<char_terminal, print(proto::_value)>
+ /// >
+ /// {};
+ ///
+ /// proto::literal<int> i(1);
+ /// proto::literal<char> c('a');
+ /// my_transforms trx;
+ ///
+ /// // Evaluate "i+c" using my_grammar with the specified transforms:
+ /// my_grammar()(i + c, 0, trx);
+ /// \endcode
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_MAP_SIZE, typename T, mpl::na)>
+ struct external_transforms
+ {
+ typedef mpl::map<BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_MAP_SIZE, T)> map_type;
+
+ template<typename Rule>
+ struct when
+ : proto::when<_, typename mpl::at<map_type, Rule>::type>
+ {};
+ };
+
#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/when.hpp>))
#include BOOST_PP_ITERATE()
+ /// INTERNAL ONLY
+ ///
+ template<typename Grammar, typename Transform>
+ struct is_callable<when<Grammar, Transform> >
+ : mpl::true_
+ {};
+
}} // namespace boost::proto
#endif
@@ -138,6 +231,8 @@
struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))>
: transform<when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))> >
{
+ typedef Grammar first;
+ typedef R second(BOOST_PP_ENUM_PARAMS(N, A));
typedef typename Grammar::proto_grammar proto_grammar;
// Note: do not evaluate is_callable<R> in this scope.
Modified: branches/release/libs/proto/doc/reference.xml
==============================================================================
--- branches/release/libs/proto/doc/reference.xml (original)
+++ branches/release/libs/proto/doc/reference.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -257,6 +257,16 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::external_transform">proto::external_transform</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::external_transforms">proto::external_transforms</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::fold">proto::fold</classname>
</computeroutput>
</listitem>
@@ -307,6 +317,11 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::functional::first">proto::functional::first</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::functional::flatten">proto::functional::flatten</classname>
</computeroutput>
</listitem>
@@ -322,11 +337,31 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::functional::make_pair">proto::functional::make_pair</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::functional::pop_back">proto::functional::pop_back</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::functional::pop_front">proto::functional::pop_front</classname>
</computeroutput>
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::functional::push_back">proto::functional::push_back</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::functional::push_front">proto::functional::push_front</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::functional::reverse">proto::functional::reverse</classname>
</computeroutput>
</listitem>
@@ -337,6 +372,11 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::functional::second">proto::functional::second</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::functional::unpack_expr">proto::functional::unpack_expr</classname>
</computeroutput>
</listitem>
@@ -402,6 +442,11 @@
</listitem>
<listitem>
<computeroutput>
+ <classname alt="boost::proto::is_transform">proto::is_transform</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
<classname alt="boost::proto::lazy">proto::lazy</classname>
</computeroutput>
</listitem>
@@ -1058,6 +1103,15 @@
<xi:include href="reference/eval.xml"/>
<xi:include href="reference/expr.xml"/>
<xi:include href="reference/extends.xml"/>
+ <xi:include href="reference/functional.xml"/>
+ <xi:include href="reference/functional/fusion.xml"/>
+ <xi:include href="reference/functional/fusion/pop_back.xml"/>
+ <xi:include href="reference/functional/fusion/pop_front.xml"/>
+ <xi:include href="reference/functional/fusion/push_back.xml"/>
+ <xi:include href="reference/functional/fusion/push_front.xml"/>
+ <xi:include href="reference/functional/fusion/reverse.xml"/>
+ <xi:include href="reference/functional/std.xml"/>
+ <xi:include href="reference/functional/std/utility.xml"/>
<xi:include href="reference/fusion.xml"/>
<xi:include href="reference/generate.xml"/>
<xi:include href="reference/literal.xml"/>
Modified: branches/release/libs/proto/doc/reference/fusion.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/fusion.xml (original)
+++ branches/release/libs/proto/doc/reference/fusion.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -69,144 +69,6 @@
</method-group>
</struct>
- <!-- proto::functional::pop_front -->
- <struct name="pop_front">
- <purpose>A <conceptname>PolymorphicFunctionObject</conceptname> type that invokes the
- <computeroutput>fusion::pop_front()</computeroutput> algorithm on its argument.</purpose>
- <description>
- <para>
- A <conceptname>PolymorphicFunctionObject</conceptname> type that invokes the
- <computeroutput>fusion::pop_front()</computeroutput> algorithm on its argument. This is
- useful for defining a <conceptname>CallableTransform</conceptname> such as
- <computeroutput>pop_front(_)</computeroutput>, which removes the first child from a Proto
- expression node. Such a transform might be used as the first argument to the
- <computeroutput><classname alt="proto::fold">proto::fold<></classname></computeroutput>
- transform; that is, fold all but the first child.
- </para>
- </description>
- <inherit>
- <type><classname>proto::callable</classname></type>
- </inherit>
- <struct-specialization name="result">
- <template>
- <template-type-parameter name="This"/>
- <template-type-parameter name="Expr"/>
- </template>
- <specialization>
- <template-arg>This(Expr)</template-arg>
- </specialization>
- <inherit>
- <type>result< This(Expr const &) ></type>
- </inherit>
- </struct-specialization>
- <struct-specialization name="result">
- <template>
- <template-type-parameter name="This"/>
- <template-type-parameter name="Expr"/>
- </template>
- <specialization>
- <template-arg>This(Expr &)</template-arg>
- </specialization>
- <inherit>
- <type>fusion::result_of::pop_front< Expr ></type>
- </inherit>
- </struct-specialization>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>typename fusion::result_of::pop_front< Expr >::type</type>
- <template>
- <template-type-parameter name="Expr"/>
- </template>
- <parameter name="expr">
- <paramtype>Expr &</paramtype>
- </parameter>
- <returns>
- <para><computeroutput>fusion::pop_front(expr)</computeroutput></para>
- </returns>
- </method>
- <method name="operator()" cv="const">
- <type>typename fusion::result_of::pop_front< Expr const >::type</type>
- <template>
- <template-type-parameter name="Expr"/>
- </template>
- <parameter name="expr">
- <paramtype>Expr const &</paramtype>
- </parameter>
- <returns>
- <para><computeroutput>fusion::pop_front(expr)</computeroutput></para>
- </returns>
- </method>
- </method-group>
- </struct>
-
- <!-- proto::functional::reverse -->
- <struct name="reverse">
- <purpose>A <conceptname>PolymorphicFunctionObject</conceptname> type that invokes the
- <computeroutput>fusion::reverse()</computeroutput> algorithm on its argument.
- </purpose>
- <description>
- <para>
- A <conceptname>PolymorphicFunctionObject</conceptname> type that invokes the
- <computeroutput>fusion::reverse()</computeroutput> algorithm on its argument. This is
- useful for defining a <conceptname>CallableTransform</conceptname> like
- <computeroutput>reverse(_)</computeroutput>, which reverses the order of the children
- of a Proto expression node.
- </para>
- </description>
- <inherit>
- <type><classname>proto::callable</classname></type>
- </inherit>
- <struct-specialization name="result">
- <template>
- <template-type-parameter name="This"/>
- <template-type-parameter name="Expr"/>
- </template>
- <specialization>
- <template-arg>This(Expr)</template-arg>
- </specialization>
- <inherit>
- <type>result< This(Expr const &) ></type>
- </inherit>
- </struct-specialization>
- <struct-specialization name="result">
- <template>
- <template-type-parameter name="This"/>
- <template-type-parameter name="Expr"/>
- </template>
- <specialization>
- <template-arg>This(Expr &)</template-arg>
- </specialization>
- <inherit>
- <type>fusion::result_of::reverse< Expr ></type>
- </inherit>
- </struct-specialization>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>typename fusion::result_of::reverse< Expr >::type</type>
- <template>
- <template-type-parameter name="Expr"/>
- </template>
- <parameter name="expr">
- <paramtype>Expr &</paramtype>
- </parameter>
- <returns>
- <para><computeroutput>fusion::reverse(expr)</computeroutput></para>
- </returns>
- </method>
- <method name="operator()" cv="const">
- <type>typename fusion::result_of::reverse< Expr const >::type</type>
- <template>
- <template-type-parameter name="Expr"/>
- </template>
- <parameter name="expr">
- <paramtype>Expr const &</paramtype>
- </parameter>
- <returns>
- <para><computeroutput>fusion::reverse(expr)</computeroutput></para>
- </returns>
- </method>
- </method-group>
- </struct>
</namespace>
<namespace name="result_of">
Modified: branches/release/libs/proto/doc/reference/proto_fwd.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/proto_fwd.xml (original)
+++ branches/release/libs/proto/doc/reference/proto_fwd.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -163,9 +163,27 @@
<typedef name="_flatten">
<type><classname>proto::functional::flatten</classname></type>
</typedef>
+ <typedef name="_make_pair">
+ <type><classname>proto::functional::make_pair</classname></type>
+ </typedef>
+ <typedef name="_first">
+ <type><classname>proto::functional::first</classname></type>
+ </typedef>
+ <typedef name="_second">
+ <type><classname>proto::functional::second</classname></type>
+ </typedef>
+ <typedef name="_pop_back">
+ <type><classname>proto::functional::pop_back</classname></type>
+ </typedef>
<typedef name="_pop_front">
<type><classname>proto::functional::pop_front</classname></type>
</typedef>
+ <typedef name="_push_back">
+ <type><classname>proto::functional::push_back</classname></type>
+ </typedef>
+ <typedef name="_push_front">
+ <type><classname>proto::functional::push_front</classname></type>
+ </typedef>
<typedef name="_reverse">
<type><classname>proto::functional::reverse</classname></type>
</typedef>
Modified: branches/release/libs/proto/doc/reference/traits.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/traits.xml (original)
+++ branches/release/libs/proto/doc/reference/traits.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -16,6 +16,7 @@
</para>
<namespace name="boost">
<namespace name="proto">
+
<struct name="is_callable">
<template>
<template-type-parameter name="T"/>
@@ -66,6 +67,51 @@
<inherit><type>mpl::bool_<<replaceable>true-or-false</replaceable>></type></inherit>
</struct>
+ <struct name="is_transform">
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+ <purpose>Boolean metafunction which tells whether a type is a
+ <conceptname>PrimitiveTransform</conceptname> or not.</purpose>
+ <description>
+ <para>
+ <computeroutput>proto::is_transform<></computeroutput> is used by the
+ <computeroutput><classname alt="proto::make">proto::make<></classname></computeroutput>
+ transform to determine whether a type <computeroutput>R</computeroutput> represents a
+ <conceptname>PrimitiveTransform</conceptname> to apply, or whether it merely represents itself.
+ </para>
+ <para>
+ It is also used by the
+ <computeroutput><classname alt="proto::call">proto::call<></classname></computeroutput>
+ transform to determine whether the function types <computeroutput>R()</computeroutput>,
+ <computeroutput>R(A1)</computeroutput>, and <computeroutput>R(A1, A2)</computeroutput> should
+ be passed the expression, state and data parameters (as needed).
+ </para>
+ <para>
+ Unless specialized for a type
+ <computeroutput>T</computeroutput>, <computeroutput>proto::is_transform<T>::value</computeroutput>
+ is computed as follows:
+ <itemizedlist>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> is a class type that inherits directly or indirectly from
+ an instantiation of
+ <computeroutput><classname alt="proto::transform">proto::transform<></classname></computeroutput>,
+ <computeroutput>proto::is_transform<T>::value</computeroutput> is <computeroutput>true</computeroutput>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Otherwise, <computeroutput>proto::is_transform<T>::value</computeroutput>
+ is <computeroutput>false</computeroutput>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </description>
+ <inherit><type>mpl::bool_<<replaceable>true-or-false</replaceable>></type></inherit>
+ </struct>
+
<struct name="is_aggregate">
<template>
<template-type-parameter name="T"/>
Modified: branches/release/libs/proto/doc/reference/transform/call.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/transform/call.xml (original)
+++ branches/release/libs/proto/doc/reference/transform/call.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -41,6 +41,12 @@
<type><replaceable>see-below</replaceable></type>
<description>
<para>
+ In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
+ <conceptname>PrimitiveTransform</conceptname> concept if
+ <computeroutput><classname>proto::is_transform</classname><T>::value</computeroutput> is
+ <computeroutput>true</computeroutput>.
+ </para>
+ <para>
<computeroutput><classname>proto::call</classname><T>::impl<Expr,State,Data>::result_type</computeroutput>
is computed as follows:
<itemizedlist>
@@ -118,68 +124,74 @@
<paramtype>typename impl::data_param</paramtype>
</parameter>
<description>
- <para>
- <computeroutput><classname>proto::call</classname><T>::impl<Expr,State,Data>::operator()</computeroutput> behaves as follows:
- <itemizedlist>
- <listitem>
- <para>
- If <computeroutput>T</computeroutput> if of the form
- <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
- <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
- return
- <programlisting>PrimitiveTransform()(expr, state, data)</programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- If <computeroutput>T</computeroutput> is of the form
- <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
- return
- <programlisting>PrimitiveTransform()(
+ <para>
+ In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
+ <conceptname>PrimitiveTransform</conceptname> concept if
+ <computeroutput><classname>proto::is_transform</classname><T>::value</computeroutput> is
+ <computeroutput>true</computeroutput>.
+ </para>
+ <para>
+ <computeroutput><classname>proto::call</classname><T>::impl<Expr,State,Data>::operator()</computeroutput> behaves as follows:
+ <itemizedlist>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> if of the form
+ <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
+ <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
+ return
+ <programlisting>PrimitiveTransform()(expr, state, data)</programlisting>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> is of the form
+ <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
+ return
+ <programlisting>PrimitiveTransform()(
<classname>when</classname><<classname>_</classname>,A<subscript>0</subscript>>()(expr, state, data),
state,
sata
)</programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- If <computeroutput>T</computeroutput> is of the form
- <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
- return:
- <programlisting>PrimitiveTransform()(
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> is of the form
+ <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
+ return:
+ <programlisting>PrimitiveTransform()(
<classname>when</classname><<classname>_</classname>,A<subscript>0</subscript>>()(expr, state, data),
<classname>when</classname><<classname>_</classname>,A<subscript>1</subscript>>()(expr, state, data),
Data
)</programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- If <computeroutput>T</computeroutput> is of the form
- <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
- return
- <programlisting>PrimitiveTransform()(
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> is of the form
+ <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
+ return
+ <programlisting>PrimitiveTransform()(
<classname>when</classname><<classname>_</classname>,A<subscript>0</subscript>>()(expr, state, data),
<classname>when</classname><<classname>_</classname>,A<subscript>1</subscript>>()(expr, state, data),
<classname>when</classname><<classname>_</classname>,A<subscript>2</subscript>>()(expr, state, data)
)</programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- If <computeroutput>T</computeroutput> is of the form
- <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,...A<subscript>n</subscript>)</computeroutput>, then
- return:
- <programlisting>PolymorphicFunctionObject()(
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ If <computeroutput>T</computeroutput> is of the form
+ <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,...A<subscript>n</subscript>)</computeroutput>, then
+ return:
+ <programlisting>PolymorphicFunctionObject()(
<classname>when</classname><<classname>_</classname>,A<subscript>0</subscript>>()(expr, state, data),
...
<classname>when</classname><<classname>_</classname>,A<subscript>n</subscript>>()(expr, state, data)
)</programlisting>
- </para>
- </listitem>
- </itemizedlist>
- </para>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
</description>
</method>
</method-group>
Modified: branches/release/libs/proto/doc/reference/transform/make.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/transform/make.xml (original)
+++ branches/release/libs/proto/doc/reference/transform/make.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -183,8 +183,8 @@
<itemizedlist>
<listitem>
<para>
- If <computeroutput>O</computeroutput> is a <conceptname>Transform</conceptname>, then let
- the result type be
+ If <computeroutput><classname>proto::is_transform</classname><O>::value</computeroutput> is
+ <computeroutput>true</computeroutput>, then let the result type be
<computeroutput>
boost::result_of<<classname>proto::when</classname><<classname>_</classname>, O>(Expr, State, Data)>::type
</computeroutput>.
@@ -243,6 +243,18 @@
<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: branches/release/libs/proto/doc/reference/transform/when.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/transform/when.xml (original)
+++ branches/release/libs/proto/doc/reference/transform/when.xml 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -69,7 +69,7 @@
<template-arg>Grammar</template-arg>
<template-arg>Fun *</template-arg>
</specialization>
- <inherit><classname>proto::when</classname>< Grammar, Fun ></inherit>
+ <inherit><type><classname>proto::when</classname>< Grammar, Fun ></type></inherit>
<purpose>A specialization that treats function pointer <conceptname>Transform</conceptname>s as if they
were function type <conceptname>Transform</conceptname>s.</purpose>
<description>
@@ -97,8 +97,8 @@
<template-arg>Grammar</template-arg>
<template-arg>R(A...)</template-arg>
</specialization>
- <inherit><classname>proto::transform</classname>< when<Grammar, R(A...)> ></inherit>
- <purpose>A grammar element and a <conceptname>PrimitiveTransform</conceptname> that associates a
+ <inherit><type><classname>proto::transform</classname>< when<Grammar, R(A...)> ></type></inherit>
+ <purpose>A grammar element and a <conceptname>Transform</conceptname> that associates a
transform with the grammar. </purpose>
<description>
<para>
@@ -124,7 +124,7 @@
<template-type-parameter name="State"/>
<template-type-parameter name="Data"/>
</template>
- <inherit><classname>proto::transform_impl</classname>< Expr, State, Data ></inherit>
+ <inherit><type><classname>proto::transform_impl</classname>< Expr, State, Data ></type></inherit>
<typedef name="call_">
<purpose>For exposition only</purpose>
<type><classname>proto::call</classname><R(A...)></type>
@@ -188,12 +188,59 @@
<type>typename Grammar::proto_grammar</type>
</typedef>
</struct-specialization>
+
+ <struct-specialization name="when">
+ <template>
+ <template-type-parameter name="Grammar"/>
+ </template>
+ <specialization>
+ <template-arg>Grammar</template-arg>
+ <template-arg><classname>proto::external_transform</classname></template-arg>
+ </specialization>
+ <inherit><type>
+ <classname>proto::transform</classname>< when<Grammar, <classname>proto::external_transform</classname>> ></type></inherit>
+ <purpose>A grammar element that associates an externally-specified transform with the grammar.
+ The transform is looked up in the Data parameter using the Grammar as a key.</purpose>
+ <description>
+ <para>
+ Use <computeroutput>proto::when<></computeroutput> to override a grammar's default
+ transform with a custom transform. It is for use when composing larger transforms by associating
+ smaller transforms with individual rules in your grammar.
+ </para>
+ <para>
+ The <computeroutput>when<G, <classname>proto::external_transform</classname>></computeroutput>
+ indicates that the associated transform is not yet known. It should be looked up when the transform
+ is about to be applied. It is found by looking it up in the passed-in Data parameter, which
+ behaves like a compile-time map from grammar types to transform types. The map is indexed using
+ <computeroutput>Grammar</computeroutput> as a key. The associated value type is used as the transform
+ to apply. In this way, the same grammar can be used to define multiple evaluating strategies that
+ can be added post-hoc.
+ </para>
+ <para>
+ See <computeroutput><classname>proto::external_transforms</classname></computeroutput> for an example.
+ </para>
+ </description>
+ <struct name="impl">
+ <template>
+ <template-type-parameter name="Expr"/>
+ <template-type-parameter name="State"/>
+ <template-type-parameter name="Data"/>
+ </template>
+ <inherit><type>
+ boost::remove_reference< Data >::type
+ ::template when< Grammar >
+ ::template impl< Expr, State, Data ></type></inherit>
+ </struct>
+ <typedef name="proto_grammar">
+ <type>typename Grammar::proto_grammar</type>
+ </typedef>
+ </struct-specialization>
<struct name="otherwise">
<template>
<template-type-parameter name="Fun"/>
</template>
- <inherit><classname>proto::when</classname>< <classname>proto::_</classname>, Fun ></inherit>
+ <inherit><type><classname>proto::when</classname>< <classname>proto::_</classname>, Fun ></type></inherit>
<purpose>
Syntactic sugar for <computeroutput><classname>proto::when</classname>< <classname>proto::_</classname>, Fun ></computeroutput>,
for use in grammars to handle all the cases not yet handled.
@@ -216,6 +263,86 @@
</para>
</description>
</struct>
+
+ <struct name="external_transform">
+ <purpose>A placeholder for use as the second parameter for <computeroutput><classname>proto::when</classname></computeroutput>
+ to indicate that the rule's transform is specified externally.</purpose>
+ <description>
+ <para>
+ See <computeroutput><classname>proto::external_transforms</classname></computeroutput> for an example.
+ </para>
+ </description>
+ </struct>
+
+ <struct name="external_transforms">
+ <template>
+ <template-type-parameter name="When" pack="1"/>
+ </template>
+ <purpose>A map from grammars to transforms, used as a way to externally associate transforms.</purpose>
+ <typedef name="map_type">
+ <purpose>For exposition only.</purpose>
+ <type>mpl::map< typename to_mpl_pair< When >::type... ></type>
+ </typedef>
+ <struct name="when">
+ <template>
+ <template-type-parameter name="Grammar"/>
+ </template>
+ <inherit><type><classname>proto::otherwise</classname>< typename mpl::at< map_type, Grammar >::type ></type></inherit>
+ </struct>
+ <description>
+ <para>
+ It is sometimes desirable to define a grammar that can be customized with different sets of transforms.
+ To do that, where you would normally specify a transform within a grammar, you can instead put
+ <computeroutput><classname>proto::external_transform</classname></computeroutput>; for example:
+ <computeroutput>proto::when< some_grammar, proto::external_transform ></computeroutput>. Then, when
+ invoking the grammar, you can pass an approriately-defined instance of <computeroutput>proto::external_transforms</computeroutput>
+ as the Data parameter. When an expression matches <computeroutput>some_grammar</computeroutput>, Proto
+ will look up the approprite transform in the Data parameter using <computeroutput>some_grammar</computeroutput>
+ as a key.
+ </para>
+ <para>
+ <programlisting>struct int_terminal
+ : <classname>proto::terminal</classname><int>
+{};
+
+struct char_terminal
+ : <classname>proto::terminal</classname><char>
+{};
+
+struct my_grammar
+ : <classname>proto::or_</classname><
+ // The next two grammar rules are customization points.
+ // The associated transforms are specified externally
+ // using external_transforms below.
+ <classname>proto::when</classname>< int_terminal, <classname>proto::external_transform</classname> >
+ , <classname>proto::when</classname>< char_terminal, <classname>proto::external_transform</classname> >
+ , <classname>proto::when</classname><
+ <classname>proto::plus</classname>< my_grammar, my_grammar >
+ , <classname>proto::fold</classname>< <classname>proto::_</classname>, int(), my_grammar >
+ >
+ >
+{};
+
+// Here is where the transforms are associated with the
+// grammar rules above.
+struct my_transforms
+ : proto::external_transforms<
+ <classname>proto::when</classname><int_terminal, print(<classname>proto::_value</classname>)>
+ , <classname>proto::when</classname><char_terminal, print(<classname>proto::_value</classname>)>
+ >
+{};
+
+// ...
+
+<classname>proto::literal</classname><int> i(1);
+<classname>proto::literal</classname><char> c('a');
+my_transforms trx;
+
+// Evaluate "i+c" using my_grammar with the specified transforms:
+my_grammar()(i + c, 0, trx);</programlisting>
+ </para>
+ </description>
+ </struct>
</namespace>
</namespace>
</header>
Modified: branches/release/libs/proto/test/examples.cpp
==============================================================================
--- branches/release/libs/proto/test/examples.cpp (original)
+++ branches/release/libs/proto/test/examples.cpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -10,6 +10,7 @@
#include <boost/mpl/min_max.hpp>
#include <boost/proto/core.hpp>
#include <boost/proto/transform.hpp>
+#include <boost/proto/functional/fusion.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/fusion/include/cons.hpp>
#include <boost/fusion/include/tuple.hpp>
Modified: branches/release/libs/proto/test/matches.cpp
==============================================================================
--- branches/release/libs/proto/test/matches.cpp (original)
+++ branches/release/libs/proto/test/matches.cpp 2010-12-10 23:33:22 EST (Fri, 10 Dec 2010)
@@ -102,6 +102,19 @@
struct a_template
{};
+template<typename Expr>
+struct my_expr;
+
+struct my_domain
+ : proto::domain<proto::pod_generator<my_expr> >
+{};
+
+template<typename Expr>
+struct my_expr
+{
+ BOOST_PROTO_BASIC_EXTENDS(Expr, my_expr, my_domain)
+};
+
void test_matches()
{
assert_matches< _ >( lit(1) );
@@ -282,6 +295,12 @@
a_template<int[3]> a;
assert_matches< proto::terminal< a_template<_> > >( lit(a) );
}
+
+ // Test that the actual derived expression type makes it through to proto::if_
+ {
+ my_expr<proto::terminal<int>::type> e = {{1}};
+ assert_matches< proto::if_<boost::is_same<domain_of<_>, my_domain>()> >( e );
+ }
}
using namespace unit_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