Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71978 - in trunk: boost/proto boost/proto/detail boost/proto/detail/preprocessed libs/proto/doc libs/proto/doc/reference
From: eric_at_[hidden]
Date: 2011-05-16 08:42:12


Author: eric_niebler
Date: 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
New Revision: 71978
URL: http://svn.boost.org/trac/boost/changeset/71978

Log:
better integration of proto::basic_expr to avoid accidental needless instantiations of proto::expr
Text files modified:
   trunk/boost/proto/detail/basic_expr.hpp | 2
   trunk/boost/proto/detail/deduce_domain.hpp | 40 ++++++++++++++++++++++++++
   trunk/boost/proto/detail/preprocessed/basic_expr.hpp | 22 +++++++-------
   trunk/boost/proto/domain.hpp | 7 ++++
   trunk/boost/proto/generate.hpp | 61 ++++++++++++++++++++++++++++++++-------
   trunk/boost/proto/operators.hpp | 4 +-
   trunk/boost/proto/proto_fwd.hpp | 4 ++
   trunk/libs/proto/doc/reference.xml | 10 ++++++
   trunk/libs/proto/doc/reference/domain.xml | 31 +++++++++++++++----
   trunk/libs/proto/doc/reference/expr.xml | 2
   trunk/libs/proto/doc/reference/generate.xml | 13 +++++++
   11 files changed, 161 insertions(+), 35 deletions(-)

Modified: trunk/boost/proto/detail/basic_expr.hpp
==============================================================================
--- trunk/boost/proto/detail/basic_expr.hpp (original)
+++ trunk/boost/proto/detail/basic_expr.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -98,7 +98,7 @@
         typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
         #endif
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;

Modified: trunk/boost/proto/detail/deduce_domain.hpp
==============================================================================
--- trunk/boost/proto/detail/deduce_domain.hpp (original)
+++ trunk/boost/proto/detail/deduce_domain.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -70,10 +70,20 @@
               : domain_<not_a_domain>
             {};
 
+ template<>
+ struct domain_<basic_default_domain>
+ : domain_<not_a_domain>
+ {};
+
             sized_type<1>::type default_test(void*, void*);
             sized_type<2>::type default_test(domain_<default_domain>*, void*);
+ sized_type<2>::type default_test(domain_<basic_default_domain>*, void*);
             sized_type<3>::type default_test(void*, domain_<default_domain>*);
+ sized_type<3>::type default_test(void*, domain_<basic_default_domain>*);
             sized_type<4>::type default_test(domain_<default_domain>*, domain_<default_domain>*);
+ sized_type<4>::type default_test(domain_<basic_default_domain>*, domain_<default_domain>*);
+ sized_type<4>::type default_test(domain_<default_domain>*, domain_<basic_default_domain>*);
+ sized_type<4>::type default_test(domain_<basic_default_domain>*, domain_<basic_default_domain>*);
 
         #ifdef BOOST_NO_DECLTYPE
             template<int N, typename Domain>
@@ -131,18 +141,48 @@
                 typedef D0 type;
             };
 
+ template<typename D0>
+ struct common_domain2<D0, basic_default_domain, 4>
+ {
+ typedef D0 type;
+ };
+
             template<typename D1>
             struct common_domain2<default_domain, D1, 4>
             {
                 typedef D1 type;
             };
 
+ template<typename D1>
+ struct common_domain2<basic_default_domain, D1, 4>
+ {
+ typedef D1 type;
+ };
+
             template<>
             struct common_domain2<default_domain, default_domain, 4>
             {
                 typedef default_domain type;
             };
 
+ template<>
+ struct common_domain2<basic_default_domain, default_domain, 4>
+ {
+ typedef default_domain type;
+ };
+
+ template<>
+ struct common_domain2<default_domain, basic_default_domain, 4>
+ {
+ typedef default_domain type;
+ };
+
+ template<>
+ struct common_domain2<basic_default_domain, basic_default_domain, 4>
+ {
+ typedef basic_default_domain type;
+ };
+
             template<typename E0, typename E1>
             struct deduce_domain2
               : common_domain2<

Modified: trunk/boost/proto/detail/preprocessed/basic_expr.hpp
==============================================================================
--- trunk/boost/proto/detail/preprocessed/basic_expr.hpp (original)
+++ trunk/boost/proto/detail/preprocessed/basic_expr.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -42,7 +42,7 @@
         typedef basic_expr proto_base_expr;
         typedef term<Arg0> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -116,7 +116,7 @@
         typedef basic_expr proto_base_expr;
         typedef list1<Arg0> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -196,7 +196,7 @@
         typedef basic_expr proto_base_expr;
         typedef list2<Arg0 , Arg1> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -264,7 +264,7 @@
         typedef basic_expr proto_base_expr;
         typedef list3<Arg0 , Arg1 , Arg2> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -332,7 +332,7 @@
         typedef basic_expr proto_base_expr;
         typedef list4<Arg0 , Arg1 , Arg2 , Arg3> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -400,7 +400,7 @@
         typedef basic_expr proto_base_expr;
         typedef list5<Arg0 , Arg1 , Arg2 , Arg3 , Arg4> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -468,7 +468,7 @@
         typedef basic_expr proto_base_expr;
         typedef list6<Arg0 , Arg1 , Arg2 , Arg3 , Arg4 , Arg5> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -536,7 +536,7 @@
         typedef basic_expr proto_base_expr;
         typedef list7<Arg0 , Arg1 , Arg2 , Arg3 , Arg4 , Arg5 , Arg6> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -604,7 +604,7 @@
         typedef basic_expr proto_base_expr;
         typedef list8<Arg0 , Arg1 , Arg2 , Arg3 , Arg4 , Arg5 , Arg6 , Arg7> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -672,7 +672,7 @@
         typedef basic_expr proto_base_expr;
         typedef list9<Arg0 , Arg1 , Arg2 , Arg3 , Arg4 , Arg5 , Arg6 , Arg7 , Arg8> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;
@@ -740,7 +740,7 @@
         typedef basic_expr proto_base_expr;
         typedef list10<Arg0 , Arg1 , Arg2 , Arg3 , Arg4 , Arg5 , Arg6 , Arg7 , Arg8 , Arg9> proto_args;
         typedef basic_expr proto_grammar;
- typedef default_domain proto_domain;
+ typedef basic_default_domain proto_domain;
         typedef default_generator proto_generator;
         typedef proto::tag::proto_expr fusion_tag;
         typedef basic_expr proto_derived_expr;

Modified: trunk/boost/proto/domain.hpp
==============================================================================
--- trunk/boost/proto/domain.hpp (original)
+++ trunk/boost/proto/domain.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -200,6 +200,13 @@
           : domain<>
         {};
 
+ /// \brief A domain to use when you prefer the use of
+ /// \c proto::basic_expr\<\> over \c proto::expr\<\>.
+ ///
+ struct basic_default_domain
+ : domain<basic_default_generator>
+ {};
+
         /// \brief A pseudo-domain for use in functions and
         /// metafunctions that require a domain parameter. It
         /// indicates that the domain of the parent node should

Modified: trunk/boost/proto/generate.hpp
==============================================================================
--- trunk/boost/proto/generate.hpp (original)
+++ trunk/boost/proto/generate.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -72,6 +72,18 @@
         #include <boost/proto/detail/generate_by_value.hpp>
     }
 
+ /// \brief Annotate a generator to indicate that it would
+ /// prefer to be passed instances of \c proto::basic_expr\<\> rather
+ /// than \c proto::expr\<\>. <tt>use_basic_expr\<Generator\></tt> is
+ /// itself a generator.
+ ///
+ template<typename Generator>
+ struct use_basic_expr
+ : Generator
+ {
+ BOOST_PROTO_USE_BASIC_EXPR()
+ };
+
     /// \brief A simple generator that passes an expression
     /// through unchanged.
     ///
@@ -107,6 +119,19 @@
         }
     };
 
+ /// \brief A simple generator that passes an expression
+ /// through unchanged and specifies a preference for
+ /// \c proto::basic_expr\<\> over \c proto::expr\<\>.
+ ///
+ /// Generators are intended for use as the first template parameter
+ /// to the \c domain\<\> class template and control if and how
+ /// expressions within that domain are to be customized.
+ /// The \c default_generator makes no modifications to the expressions
+ /// passed to it.
+ struct basic_default_generator
+ : proto::use_basic_expr<default_generator>
+ {};
+
     /// \brief A generator that wraps expressions passed
     /// to it in the specified extension wrapper.
     ///
@@ -307,18 +332,6 @@
         }
     };
 
- /// \brief Annotate a generator to indicate that it would
- /// prefer to be passed instances of \c proto::basic_expr\<\> rather
- /// than \c proto::expr\<\>. <tt>use_basic_expr\<Generator\></tt> is
- /// itself a generator.
- ///
- template<typename Generator>
- struct use_basic_expr
- : Generator
- {
- BOOST_PROTO_USE_BASIC_EXPR()
- };
-
     /// \brief Tests a generator to see whether it would prefer
     /// to be passed instances of \c proto::basic_expr\<\> rather than
     /// \c proto::expr\<\>.
@@ -376,11 +389,23 @@
     };
 
     template<typename Expr>
+ struct result_of<proto::basic_default_domain(Expr)>
+ {
+ typedef Expr type;
+ };
+
+ template<typename Expr>
     struct result_of<proto::default_generator(Expr)>
     {
         typedef Expr type;
     };
 
+ template<typename Expr>
+ struct result_of<proto::basic_default_generator(Expr)>
+ {
+ typedef Expr type;
+ };
+
     #if BOOST_VERSION >= 104400
     template<typename Expr>
     struct tr1_result_of<proto::default_domain(Expr)>
@@ -389,10 +414,22 @@
     };
 
     template<typename Expr>
+ struct tr1_result_of<proto::basic_default_domain(Expr)>
+ {
+ typedef Expr type;
+ };
+
+ template<typename Expr>
     struct tr1_result_of<proto::default_generator(Expr)>
     {
         typedef Expr type;
     };
+
+ template<typename Expr>
+ struct tr1_result_of<proto::basic_default_generator(Expr)>
+ {
+ typedef Expr type;
+ };
     #endif
 }
 

Modified: trunk/boost/proto/operators.hpp
==============================================================================
--- trunk/boost/proto/operators.hpp (original)
+++ trunk/boost/proto/operators.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -34,7 +34,7 @@
           : boost::lazy_enable_if_c<
                 boost::mpl::and_<
                     Trait
- , lazy_matches<result_of::make_expr<Tag, default_domain, Arg &>, Grammar>
+ , lazy_matches<result_of::make_expr<Tag, basic_default_domain, Arg &>, Grammar>
>::value
               , result_of::make_expr<Tag, Domain, Arg &>
>
@@ -64,7 +64,7 @@
           : boost::lazy_enable_if_c<
                 boost::mpl::and_<
                     Trait
- , lazy_matches<result_of::make_expr<Tag, default_domain, Left &, Right &>, Grammar>
+ , lazy_matches<result_of::make_expr<Tag, basic_default_domain, Left &, Right &>, Grammar>
>::value
               , result_of::make_expr<Tag, Domain, Left &, Right &>
>

Modified: trunk/boost/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/proto/proto_fwd.hpp (original)
+++ trunk/boost/proto/proto_fwd.hpp 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -270,6 +270,8 @@
     ////////////////////////////////////////////////////////////////////////////////////////////////
     struct default_generator;
 
+ struct basic_default_generator;
+
     template<template<typename> class Extends>
     struct generator;
 
@@ -301,6 +303,8 @@
 
         struct default_domain;
 
+ struct basic_default_domain;
+
         struct deduce_domain;
 
         template<typename Domain, typename Tag, typename Args, bool WantsBasicExpr = wants_basic_expr<typename Domain::proto_generator>::value>

Modified: trunk/libs/proto/doc/reference.xml
==============================================================================
--- trunk/libs/proto/doc/reference.xml (original)
+++ trunk/libs/proto/doc/reference.xml 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -77,6 +77,16 @@
       </listitem>
       <listitem>
         <computeroutput>
+ <classname alt="boost::proto::basic_default_domain">proto::basic_default_domain</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
+ <classname alt="boost::proto::basic_default_generator">proto::basic_default_generator</classname>
+ </computeroutput>
+ </listitem>
+ <listitem>
+ <computeroutput>
           <classname alt="boost::proto::basic_expr">proto::basic_expr</classname>
         </computeroutput>
       </listitem>

Modified: trunk/libs/proto/doc/reference/domain.xml
==============================================================================
--- trunk/libs/proto/doc/reference/domain.xml (original)
+++ trunk/libs/proto/doc/reference/domain.xml 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -236,6 +236,13 @@
           to associate a domain with an expression.</purpose>
       </struct>
 
+ <!-- proto::basic_default_domain -->
+ <struct name="basic_default_domain">
+ <inherit><classname>proto::domain</classname>&lt; <classname>proto::basic_default_generator</classname> &gt;</inherit>
+ <purpose>A domain similiar in purpose to <classname>proto::default_domain</classname>, except stating
+ a preference for <classname>proto::basic_expr</classname>&lt;&gt; over <classname>proto::expr</classname>&lt;&gt;.</purpose>
+ </struct>
+
       <!-- proto::deduce_domain -->
       <struct name="deduce_domain">
         <purpose>A pseudo-domain for use in functions and metafunctions that require a domain parameter.
@@ -256,8 +263,14 @@
                 A sub-domain is <emphasis>stronger</emphasis> than its super-domain.
               </listitem>
               <listitem>
- <computeroutput><classname>proto::default_domain</classname></computeroutput>
- and all its sub-domains are <emphasis>weaker</emphasis> than all other domains.
+ <computeroutput><classname>proto::default_domain</classname></computeroutput>,
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>
+ and all their sub-domains are <emphasis>weaker</emphasis> than all other domains.
+ </listitem>
+ <listitem>
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>
+ is weaker than
+ <computeroutput><classname>proto::default_domain</classname></computeroutput>.
               </listitem>
               <listitem>
                 For each child, define a set of domains <emphasis>S<subscript>N</subscript></emphasis>
@@ -266,12 +279,14 @@
               <listitem>
                 Define a set <emphasis>I<subscript>S</subscript></emphasis> that is the intersection of
                 all the individual sets <emphasis>S<subscript>N</subscript></emphasis> that don't contain
- <computeroutput><classname>proto::default_domain</classname></computeroutput>.
+ <computeroutput><classname>proto::default_domain</classname></computeroutput> or
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>.
               </listitem>
               <listitem>
                 Define a set <emphasis>I<subscript>W</subscript></emphasis> that is the intersection of
                 all the individual sets <emphasis>S<subscript>N</subscript></emphasis> that contain
- <computeroutput><classname>proto::default_domain</classname></computeroutput>.
+ <computeroutput><classname>proto::default_domain</classname></computeroutput> or
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>.
               </listitem>
               <listitem>
                 Define a set <emphasis>P</emphasis> that is the union of
@@ -280,14 +295,16 @@
               </listitem>
               <listitem>
                 The common domain is the strongest domain in set <emphasis>P</emphasis>, with the
- following caveat.
+ following caveats.
               </listitem>
               <listitem>
                 Let <emphasis>U</emphasis> be the union of all sets
                 <emphasis>S<subscript>N</subscript></emphasis>. If the result is
- <computeroutput><classname>proto::default_domain</classname></computeroutput>
+ <computeroutput><classname>proto::default_domain</classname></computeroutput> or
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>
                 and <emphasis>U</emphasis> contains an element that is <emphasis>not </emphasis>
- <computeroutput><classname>proto::default_domain</classname></computeroutput>,
+ <computeroutput><classname>proto::default_domain</classname></computeroutput> or
+ <computeroutput><classname>proto::basic_default_domain</classname></computeroutput>,
                 it is an error.
               </listitem>
             </itemizedlist>

Modified: trunk/libs/proto/doc/reference/expr.xml
==============================================================================
--- trunk/libs/proto/doc/reference/expr.xml (original)
+++ trunk/libs/proto/doc/reference/expr.xml 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -68,7 +68,7 @@
         </typedef>
 
         <typedef name="proto_domain">
- <type><classname>proto::default_domain</classname></type>
+ <type><classname>proto::basic_default_domain</classname></type>
         </typedef>
 
         <typedef name="proto_grammar">

Modified: trunk/libs/proto/doc/reference/generate.xml
==============================================================================
--- trunk/libs/proto/doc/reference/generate.xml (original)
+++ trunk/libs/proto/doc/reference/generate.xml 2011-05-16 08:42:10 EDT (Mon, 16 May 2011)
@@ -21,7 +21,7 @@
           </para>
         </description>
         <inherit>
- <type>proto::callable</type>
+ <type><classname>proto::callable</classname></type>
         </inherit>
         <struct-specialization name="result">
           <template>
@@ -54,6 +54,17 @@
         </method-group>
       </struct>
 
+ <!-- proto::basic_default_generator -->
+ <struct name="basic_default_generator">
+ <purpose>
+ A simple generator that passes an expression through unchanged while stating
+ a preference for <classname>proto::basic_expr</classname>&lt;&gt; over
+ <classname>proto::expr</classname>&lt;&gt;.</purpose>
+ <inherit>
+ <type><classname>proto::use_basic_expr</classname>&lt; <classname>proto::default_generator</classname> &gt;</type>
+ </inherit>
+ </struct>
+
       <!-- proto::generator -->
       <struct name="generator">
         <template>


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