Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49646 - trunk/boost/proto
From: eric_at_[hidden]
Date: 2008-11-08 03:12:15


Author: eric_niebler
Date: 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
New Revision: 49646
URL: http://svn.boost.org/trac/boost/changeset/49646

Log:
simplifications, slightly improved compile times
Text files modified:
   trunk/boost/proto/args.hpp | 190 +++++++++++++++++++--------------------
   trunk/boost/proto/deep_copy.hpp | 4
   trunk/boost/proto/expr.hpp | 2
   trunk/boost/proto/extends.hpp | 3
   trunk/boost/proto/generate.hpp | 17 +-
   trunk/boost/proto/literal.hpp | 10 +-
   trunk/boost/proto/matches.hpp | 10 +-
   trunk/boost/proto/traits.hpp | 30 ++---
   8 files changed, 130 insertions(+), 136 deletions(-)

Modified: trunk/boost/proto/args.hpp
==============================================================================
--- trunk/boost/proto/args.hpp (original)
+++ trunk/boost/proto/args.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -27,112 +27,111 @@
 
     namespace boost { namespace proto
     {
+ namespace detail
+ {
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits
+ {
+ typedef Expr value_type;
+ typedef Expr &reference;
+ typedef Expr const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits<Expr &>
+ {
+ typedef Expr value_type;
+ typedef Expr &reference;
+ typedef Expr &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits<Expr const &>
+ {
+ typedef Expr value_type;
+ typedef Expr const &reference;
+ typedef Expr const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T>
+ struct term_traits
+ {
+ typedef T value_type;
+ typedef T &reference;
+ typedef T const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T>
+ struct term_traits<T &>
+ {
+ typedef typename mpl::if_c<is_function<T>::value, T &, T>::type value_type;
+ typedef T &reference;
+ typedef T &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T>
+ struct term_traits<T const &>
+ {
+ typedef T value_type;
+ typedef T const &reference;
+ typedef T const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_traits<T (&)[N]>
+ {
+ typedef T (&value_type)[N];
+ typedef T (&reference)[N];
+ typedef T (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_traits<T const (&)[N]>
+ {
+ typedef T const (&value_type)[N];
+ typedef T const (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_traits<T[N]>
+ {
+ typedef T (&value_type)[N];
+ typedef T (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_traits<T const[N]>
+ {
+ typedef T const (&value_type)[N];
+ typedef T const (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ }
+
         ////////////////////////////////////////////////////////////////////////////////////////////
         BOOST_PROTO_BEGIN_ADL_NAMESPACE(argsns_)
 
         #define BOOST_PROTO_DEFINE_CHILD_N(Z, N, DATA) \
             typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(child, N); \
- typedef expr_ref<BOOST_PP_CAT(Arg, N)> BOOST_PP_CAT(child_ref, N); \
             /**< INTERNAL ONLY */
 
         #define BOOST_PROTO_DEFINE_VOID_N(z, n, data) \
             typedef mpl::void_ BOOST_PP_CAT(child, n); \
- typedef mpl::void_ BOOST_PP_CAT(child_ref, n); \
             /**< INTERNAL ONLY */
 
- /// INTERNAL ONLY
- template<typename Expr>
- struct expr_ref
- {
- typedef typename Expr::proto_base_expr proto_base_expr;
- typedef typename Expr::proto_derived_expr proto_derived_expr;
- typedef typename Expr::proto_tag proto_tag;
- typedef typename Expr::proto_args proto_args;
- typedef typename Expr::proto_arity proto_arity;
- typedef typename Expr::proto_domain proto_domain;
- typedef proto_derived_expr value_type;
- typedef Expr &reference;
- typedef Expr const &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename Expr>
- struct expr_ref<Expr &>
- {
- typedef typename Expr::proto_base_expr proto_base_expr;
- typedef typename Expr::proto_derived_expr proto_derived_expr;
- typedef typename Expr::proto_tag proto_tag;
- typedef typename Expr::proto_args proto_args;
- typedef typename Expr::proto_arity proto_arity;
- typedef typename Expr::proto_domain proto_domain;
- typedef proto_derived_expr value_type;
- typedef Expr &reference;
- typedef Expr &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename T>
- struct term_ref
- {
- typedef T value_type;
- typedef T &reference;
- typedef T const &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename T>
- struct term_ref<T &>
- {
- typedef typename mpl::if_c<is_function<T>::value, T &, T>::type value_type;
- typedef T &reference;
- typedef T &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename T>
- struct term_ref<T const &>
- {
- typedef T value_type;
- typedef T const &reference;
- typedef T const &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename T, std::size_t N>
- struct term_ref<T (&)[N]>
- {
- typedef T (&value_type)[N];
- typedef T (&reference)[N];
- typedef T (&const_reference)[N];
- };
-
- /// INTERNAL ONLY
- template<typename T, std::size_t N>
- struct term_ref<T const (&)[N]>
- {
- typedef T const (&value_type)[N];
- typedef T const (&reference)[N];
- typedef T const (&const_reference)[N];
- };
-
- /// INTERNAL ONLY
- template<typename T, std::size_t N>
- struct term_ref<T[N]>
- {
- typedef T (&value_type)[N];
- typedef T (&reference)[N];
- typedef T const (&const_reference)[N];
- };
-
- /// INTERNAL ONLY
- template<typename T, std::size_t N>
- struct term_ref<T const[N]>
- {
- typedef T const (&value_type)[N];
- typedef T const (&reference)[N];
- typedef T const (&const_reference)[N];
- };
-
         /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
         ///
         /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
@@ -142,7 +141,6 @@
         {
             BOOST_STATIC_CONSTANT(long, arity = 0);
             typedef Arg0 child0;
- typedef term_ref<Arg0> child_ref0;
 
             #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
             BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~)

Modified: trunk/boost/proto/deep_copy.hpp
==============================================================================
--- trunk/boost/proto/deep_copy.hpp (original)
+++ trunk/boost/proto/deep_copy.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -136,7 +136,9 @@
         {
         #define BOOST_PROTO_DEFINE_DEEP_COPY_TYPE(Z, N, DATA) \
             typename deep_copy_impl< \
- typename Expr::BOOST_PP_CAT(proto_child_ref, N)::proto_derived_expr \
+ typename remove_reference< \
+ typename Expr::BOOST_PP_CAT(proto_child, N) \
+ >::type::proto_derived_expr \
>::type \
             /**/
 

Modified: trunk/boost/proto/expr.hpp
==============================================================================
--- trunk/boost/proto/expr.hpp (original)
+++ trunk/boost/proto/expr.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -45,14 +45,12 @@
         #define BOOST_PROTO_CHILD(Z, N, DATA) \
             typedef typename Args::BOOST_PP_CAT(child, N) BOOST_PP_CAT(proto_child, N); \
             BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N); \
- typedef typename Args::BOOST_PP_CAT(child_ref, N) BOOST_PP_CAT(proto_child_ref, N); \
             /**< INTERNAL ONLY */
 
         /// INTERNAL ONLY
         ///
         #define BOOST_PROTO_VOID(Z, N, DATA) \
             typedef void BOOST_PP_CAT(proto_child, N); \
- typedef void BOOST_PP_CAT(proto_child_ref, N); \
             /**< INTERNAL ONLY */
 
             struct not_a_valid_type

Modified: trunk/boost/proto/extends.hpp
==============================================================================
--- trunk/boost/proto/extends.hpp (original)
+++ trunk/boost/proto/extends.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -144,9 +144,6 @@
         typedef \
             typename proto_base_expr::BOOST_PP_CAT(proto_child, N) \
         BOOST_PP_CAT(proto_child, N); \
- typedef \
- typename proto_base_expr::BOOST_PP_CAT(proto_child_ref, N) \
- BOOST_PP_CAT(proto_child_ref, N); \
         /**/
 
     #define BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain) \

Modified: trunk/boost/proto/generate.hpp
==============================================================================
--- trunk/boost/proto/generate.hpp (original)
+++ trunk/boost/proto/generate.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -17,6 +17,7 @@
     #include <boost/preprocessor/repetition/enum.hpp>
     #include <boost/utility/enable_if.hpp>
     #include <boost/proto/proto_fwd.hpp>
+ #include <boost/proto/args.hpp>
     #include <boost/proto/matches.hpp>
     #include <boost/proto/detail/suffix.hpp>
 
@@ -41,21 +42,21 @@
             };
 
             template<typename Expr>
- struct expr_traits;
+ struct expr_params;
 
             template<typename Tag, typename Args, long N>
- struct expr_traits<proto::expr<Tag, Args, N> >
+ struct expr_params<proto::expr<Tag, Args, N> >
             {
                 typedef Tag tag;
                 typedef Args args;
                 BOOST_STATIC_CONSTANT(long, arity = N);
             };
 
- template<typename Expr, long Arity = expr_traits<Expr>::arity>
+ template<typename Expr, long Arity = expr_params<Expr>::arity>
             struct by_value_generator_;
 
         #define BOOST_PROTO_DEFINE_BY_VALUE_TYPE(Z, N, Expr) \
- typename uncvref<typename expr_traits<Expr>::args::BOOST_PP_CAT(child, N)>::type \
+ typename uncvref<typename expr_params<Expr>::args::BOOST_PP_CAT(child, N)>::type \
             /**/
 
         #define BOOST_PROTO_DEFINE_BY_VALUE(Z, N, expr) \
@@ -67,8 +68,8 @@
             {
                 typedef
                     proto::expr<
- typename expr_traits<Expr>::tag
- , term<typename expr_traits<Expr>::args::child_ref0::value_type>
+ typename expr_params<Expr>::tag
+ , term<typename detail::term_traits<typename expr_params<Expr>::args::child0>::value_type>
>
                 type;
 
@@ -362,9 +363,9 @@
             {
                 typedef
                     proto::expr<
- typename expr_traits<Expr>::tag
+ typename expr_params<Expr>::tag
                       , BOOST_PP_CAT(list, N)<
- // typename expr_traits<Expr>::args::child_ref0::proto_derived_expr, ...
+ // typename uncvref<typename expr_params<Expr>::args::child0>::type, ...
                             BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_BY_VALUE_TYPE, Expr)
>
>

Modified: trunk/boost/proto/literal.hpp
==============================================================================
--- trunk/boost/proto/literal.hpp (original)
+++ trunk/boost/proto/literal.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -36,16 +36,16 @@
           , typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= default_domain)
>
         struct literal
- : extends<typename terminal<T>::type, literal<T, Domain>, Domain>
+ : extends<expr<tag::terminal, term<T> >, literal<T, Domain>, Domain>
         {
         private:
- typedef typename terminal<T>::type terminal_type;
+ typedef expr<tag::terminal, term<T> > terminal_type;
             typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
 
         public:
- typedef typename terminal_type::proto_child_ref0::value_type value_type;
- typedef typename terminal_type::proto_child_ref0::reference reference;
- typedef typename terminal_type::proto_child_ref0::const_reference const_reference;
+ typedef typename detail::term_traits<T>::value_type value_type;
+ typedef typename detail::term_traits<T>::reference reference;
+ typedef typename detail::term_traits<T>::const_reference const_reference;
 
             template<typename U>
             literal(U &u)

Modified: trunk/boost/proto/matches.hpp
==============================================================================
--- trunk/boost/proto/matches.hpp (original)
+++ trunk/boost/proto/matches.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -325,12 +325,12 @@
 
             template<typename Tag, typename Args1, typename Args2>
             struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<Tag, Args2, 1> >
- : matches_<typename Args1::child_ref0::proto_base_expr, typename Args2::child0::proto_base_expr>
+ : matches_<typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr, typename Args2::child0::proto_base_expr>
             {};
 
             template<typename Tag, typename Args1, typename Args2>
             struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<proto::_, Args2, 1> >
- : matches_<typename Args1::child_ref0::proto_base_expr, typename Args2::child0::proto_base_expr>
+ : matches_<typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr, typename Args2::child0::proto_base_expr>
             {};
 
             template<typename Args1, typename Args2>
@@ -340,7 +340,7 @@
 
         #define BOOST_PROTO_MATCHES_N_FUN(Z, N, DATA) \
             matches_< \
- typename Args1::BOOST_PP_CAT(child_ref, N)::proto_base_expr \
+ typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_base_expr\
               , typename Args2::BOOST_PP_CAT(child, N)::proto_base_expr \
>
 
@@ -944,14 +944,14 @@
             template<typename Args, typename Back, long To>
             struct vararg_matches_impl<Args, Back, N, To>
               : and2<
- matches_<typename Args::BOOST_PP_CAT(child_ref, BOOST_PP_DEC(N))::proto_base_expr, Back>::value
+ matches_<typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr, Back>::value
                   , vararg_matches_impl<Args, Back, N + 1, To>
>
             {};
 
             template<typename Args, typename Back>
             struct vararg_matches_impl<Args, Back, N, N>
- : matches_<typename Args::BOOST_PP_CAT(child_ref, BOOST_PP_DEC(N))::proto_base_expr, Back>
+ : matches_<typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr, Back>
             {};
 
             template<

Modified: trunk/boost/proto/traits.hpp
==============================================================================
--- trunk/boost/proto/traits.hpp (original)
+++ trunk/boost/proto/traits.hpp 2008-11-08 03:12:13 EST (Sat, 08 Nov 2008)
@@ -456,7 +456,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T</tt>
                 /// \li <tt>T &</tt> becomes <tt>T</tt>
                 /// \li <tt>T</tt> becomes <tt>T</tt>
- typedef typename Expr::proto_child_ref0::value_type type;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::value_type type;
             };
 
             template<typename Expr>
@@ -475,7 +475,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T &</tt>
- typedef typename Expr::proto_child_ref0::reference type;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::reference type;
             };
 
             template<typename Expr>
@@ -494,7 +494,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T const &</tt>
- typedef typename Expr::proto_child_ref0::const_reference type;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::const_reference type;
             };
 
             // TODO left<> and right<> force the instantiation of Expr.
@@ -1727,7 +1727,7 @@
                 /// \brief Return the Nth child of the given expression.
                 /// \param expr The expression node.
                 /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
- /// \pre <tt>N == 0 || N \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N \< Expr::proto_arity::value</tt>
                 /// \return <tt>proto::child_c\<N\>(expr)</tt>
                 /// \throw nothrow
                 template<typename Expr>
@@ -1770,7 +1770,7 @@
                 /// \brief Return the Nth child of the given expression.
                 /// \param expr The expression node.
                 /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
- /// \pre <tt>N::value == 0 || N::value \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N::value \< Expr::proto_arity::value</tt>
                 /// \return <tt>proto::child\<N\>(expr)</tt>
                 /// \throw nothrow
                 template<typename Expr>
@@ -2018,13 +2018,12 @@
         /// Return the Nth child of the specified Proto expression. If
         /// \c N is not specified, as in \c child(expr), then \c N is assumed
         /// to be <tt>mpl::long_\<0\></tt>. The child is returned by
- /// reference. If the expression is holding the child in a
- /// <tt>ref_\<\></tt> wrapper, it is unwrapped before it is returned.
+ /// reference.
         ///
         /// \param expr The Proto expression.
         /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
         /// \pre \c N is an MPL Integral Constant.
- /// \pre <tt>N::value == 0 || N::value \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N::value \< Expr::proto_arity::value</tt>
         /// \throw nothrow
         /// \return A reference to the Nth child
         template<typename N, typename Expr>
@@ -2046,7 +2045,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename Expr2::proto_base_expr::proto_child_ref0::reference
+ typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::reference
         child(Expr2 &expr2 BOOST_PROTO_DISABLE_IF_IS_CONST(Expr2))
         {
             return expr2.proto_base().child0;
@@ -2055,7 +2054,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename Expr2::proto_base_expr::proto_child_ref0::const_reference
+ typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::const_reference
         child(Expr2 const &expr2)
         {
             return expr2.proto_base().child0;
@@ -2064,12 +2063,11 @@
         /// \brief Return the Nth child of the specified Proto expression.
         ///
         /// Return the Nth child of the specified Proto expression. The child
- /// is returned by reference. If the expression is holding the child in
- /// a <tt>ref_\<\></tt> wrapper, it is unwrapped before it is returned.
+ /// is returned by reference.
         ///
         /// \param expr The Proto expression.
         /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
- /// \pre <tt>N == 0 || N \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N \< Expr::proto_arity::value</tt>
         /// \throw nothrow
         /// \return A reference to the Nth child
         template<long N, typename Expr>
@@ -2325,7 +2323,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T</tt>
                 /// \li <tt>T &</tt> becomes <tt>T</tt>
                 /// \li <tt>T</tt> becomes <tt>T</tt>
- typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::value_type type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::value_type type;
             };
 
             template<typename Expr>
@@ -2340,7 +2338,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T &</tt>
- typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::reference type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::reference type;
 
                 /// INTERNAL ONLY
                 ///
@@ -2362,7 +2360,7 @@
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T const &</tt>
- typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::const_reference type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::const_reference type;
 
                 /// INTERNAL ONLY
                 ///


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