Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61055 - trunk/boost/proto
From: eric_at_[hidden]
Date: 2010-04-04 19:10:00


Author: eric_niebler
Date: 2010-04-04 19:09:58 EDT (Sun, 04 Apr 2010)
New Revision: 61055
URL: http://svn.boost.org/trac/boost/changeset/61055

Log:
try to get proto working on msvc-7.1 again, misc clean-up
Text files modified:
   trunk/boost/proto/extends.hpp | 142 ++++++++++++++++++---------------------
   1 files changed, 64 insertions(+), 78 deletions(-)

Modified: trunk/boost/proto/extends.hpp
==============================================================================
--- trunk/boost/proto/extends.hpp (original)
+++ trunk/boost/proto/extends.hpp 2010-04-04 19:09:58 EDT (Sun, 04 Apr 2010)
@@ -10,6 +10,8 @@
 #define BOOST_PROTO_EXTENDS_HPP_EAN_11_1_2006
 
 #include <cstddef> // for offsetof
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
 #include <boost/preprocessor/facilities/empty.hpp>
 #include <boost/preprocessor/tuple/elem.hpp>
 #include <boost/preprocessor/control/if.hpp>
@@ -54,11 +56,11 @@
 
     /// INTERNAL ONLY
     ///
- #define BOOST_PROTO_CONST0
+ #define BOOST_PROTO_CONST() const
 
     /// INTERNAL ONLY
     ///
- #define BOOST_PROTO_CONST1 const
+ #define BOOST_PROTO_TYPENAME() typename
 
     /// INTERNAL ONLY
     ///
@@ -75,22 +77,22 @@
         typename boost::result_of< \
             proto_domain( \
                 typename boost::proto::result_of::BOOST_PP_CAT(funop, N)< \
- proto_derived_expr BOOST_PROTO_CONST ## Const \
+ proto_derived_expr Const() \
                   , proto_domain \
                     BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A) \
>::type \
             ) \
>::type const \
- operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) BOOST_PROTO_CONST ## Const \
+ operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) Const() \
         { \
             typedef boost::proto::result_of::BOOST_PP_CAT(funop, N)< \
- proto_derived_expr BOOST_PROTO_CONST ## Const \
+ proto_derived_expr Const() \
               , proto_domain \
                 BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, const A) \
> funop; \
             return proto_domain()( \
                 funop::call( \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
                     BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, a) \
                 ) \
             ); \
@@ -104,22 +106,22 @@
         typename boost::result_of< \
             proto_domain( \
                 typename boost::proto::result_of::funop< \
- proto_derived_expr BOOST_PROTO_CONST ## Const(A const &...) \
+ proto_derived_expr Const()(A const &...) \
                   , proto_derived_expr \
                   , proto_domain \
>::type \
             ) \
>::type const \
- operator ()(A const &...a) BOOST_PROTO_CONST ## Const \
+ operator ()(A const &...a) Const() \
         { \
             typedef boost::proto::result_of::funop< \
- proto_derived_expr BOOST_PROTO_CONST ## Const(A const &...) \
+ proto_derived_expr Const()(A const &...) \
               , proto_derived_expr \
               , proto_domain \
> funop; \
             return proto_domain()( \
                 funop::call( \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
                   , a... \
                 ) \
             ); \
@@ -129,12 +131,14 @@
     /// INTERNAL ONLY
     ///
     #define BOOST_PROTO_DEFINE_FUN_OP_CONST(Z, N, DATA) \
- BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, 1)
+ BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, BOOST_PROTO_CONST) \
+ /**/
 
     /// INTERNAL ONLY
     ///
     #define BOOST_PROTO_DEFINE_FUN_OP_NON_CONST(Z, N, DATA) \
- BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, 0)
+ BOOST_PROTO_DEFINE_FUN_OP_IMPL_(Z, N, DATA, BOOST_PP_EMPTY) \
+ /**/
 
     /// INTERNAL ONLY
     ///
@@ -194,37 +198,7 @@
         typedef void proto_is_aggregate_; \
         /**< INTERNAL ONLY */
 
- #define BOOST_PROTO_EXTENDS_COPY_ASSIGN_(This, Typename) \
- BOOST_PROTO_DISABLE_MSVC_C4522 \
- Typename() boost::result_of< \
- Typename() This::proto_domain( \
- boost::proto::expr< \
- boost::proto::tag::assign \
- , boost::proto::list2< \
- This & \
- , This & \
- > \
- , 2 \
- > \
- ) \
- >::type const \
- operator =(This &a) \
- { \
- typedef boost::proto::expr< \
- boost::proto::tag::assign \
- , boost::proto::list2< \
- This & \
- , This & \
- > \
- , 2 \
- > that_type; \
- that_type that = { \
- *this \
- , a \
- }; \
- return Typename() This::proto_domain()(that); \
- } \
- \
+ #define BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, Const, Typename) \
         BOOST_PROTO_DISABLE_MSVC_C4522 \
         Typename() boost::result_of< \
             Typename() This::proto_domain( \
@@ -232,19 +206,19 @@
                     boost::proto::tag::assign \
                   , boost::proto::list2< \
                         This & \
- , This const & \
+ , This Const() & \
> \
                   , 2 \
> \
             ) \
>::type const \
- operator =(This const &a) \
+ operator =(This Const() &a) \
         { \
             typedef boost::proto::expr< \
                 boost::proto::tag::assign \
               , boost::proto::list2< \
                     This & \
- , This const & \
+ , This Const() & \
> \
               , 2 \
> that_type; \
@@ -256,6 +230,19 @@
         } \
         /**/
 
+ // MSVC 8.0 and higher seem to need copy-assignment operator to be overloaded on *both*
+ // const and non-const rhs arguments.
+ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) && (BOOST_MSVC > 1310)
+ #define BOOST_PROTO_EXTENDS_COPY_ASSIGN_(This, Typename) \
+ BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, BOOST_PP_EMPTY, Typename) \
+ BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, BOOST_PROTO_CONST, Typename) \
+ /**/
+ #else
+ #define BOOST_PROTO_EXTENDS_COPY_ASSIGN_(This, Typename) \
+ BOOST_PROTO_EXTENDS_COPY_ASSIGN_IMPL_(This, BOOST_PROTO_CONST, Typename) \
+ /**/
+ #endif
+
         /// INTERNAL ONLY
         ///
     #define BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(Const) \
@@ -265,25 +252,25 @@
                 boost::proto::expr< \
                     boost::proto::tag::assign \
                   , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                       , typename boost::proto::result_of::as_child<A, proto_domain>::type \
> \
                   , 2 \
> \
             ) \
>::type const \
- operator =(A &a) BOOST_PROTO_CONST ## Const \
+ operator =(A &a) Const() \
         { \
             typedef boost::proto::expr< \
                 boost::proto::tag::assign \
               , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                   , typename boost::proto::result_of::as_child<A, proto_domain>::type \
> \
               , 2 \
> that_type; \
             that_type that = { \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
             return proto_domain()(that); \
@@ -295,25 +282,25 @@
                 boost::proto::expr< \
                     boost::proto::tag::assign \
                   , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                       , typename boost::proto::result_of::as_child<A const, proto_domain>::type \
> \
                   , 2 \
> \
             ) \
>::type const \
- operator =(A const &a) BOOST_PROTO_CONST ## Const \
+ operator =(A const &a) Const() \
         { \
             typedef boost::proto::expr< \
                 boost::proto::tag::assign \
               , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                   , typename boost::proto::result_of::as_child<A const, proto_domain>::type \
> \
               , 2 \
> that_type; \
             that_type that = { \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
             return proto_domain()(that); \
@@ -321,16 +308,16 @@
         /**/
 
     #define BOOST_PROTO_EXTENDS_ASSIGN_CONST_() \
- BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(1) \
+ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(BOOST_PROTO_CONST) \
         /**/
 
     #define BOOST_PROTO_EXTENDS_ASSIGN_NON_CONST_() \
- BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(0) \
+ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(BOOST_PP_EMPTY) \
         /**/
 
     #define BOOST_PROTO_EXTENDS_ASSIGN_() \
- BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(0) \
- BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(1) \
+ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(BOOST_PP_EMPTY) \
+ BOOST_PROTO_EXTENDS_ASSIGN_IMPL_(BOOST_PROTO_CONST) \
         /**/
 
     #define BOOST_PROTO_EXTENDS_ASSIGN_CONST() \
@@ -357,25 +344,25 @@
                 boost::proto::expr< \
                     boost::proto::tag::subscript \
                   , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                       , typename boost::proto::result_of::as_child<A, proto_domain>::type \
> \
                   , 2 \
> \
             ) \
>::type const \
- operator [](A &a) BOOST_PROTO_CONST ## Const \
+ operator [](A &a) Const() \
         { \
             typedef boost::proto::expr< \
                 boost::proto::tag::subscript \
               , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                   , typename boost::proto::result_of::as_child<A, proto_domain>::type \
> \
               , 2 \
> that_type; \
             that_type that = { \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
             return proto_domain()(that); \
@@ -387,25 +374,25 @@
                 boost::proto::expr< \
                     boost::proto::tag::subscript \
                   , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                       , typename boost::proto::result_of::as_child<A const, proto_domain>::type \
> \
                   , 2 \
> \
             ) \
>::type const \
- operator [](A const &a) BOOST_PROTO_CONST ## Const \
+ operator [](A const &a) Const() \
         { \
             typedef boost::proto::expr< \
                 boost::proto::tag::subscript \
               , boost::proto::list2< \
- proto_derived_expr BOOST_PROTO_CONST ## Const & \
+ proto_derived_expr Const() & \
                   , typename boost::proto::result_of::as_child<A const, proto_domain>::type \
> \
               , 2 \
> that_type; \
             that_type that = { \
- *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this) \
+ *static_cast<proto_derived_expr Const() *>(this) \
               , boost::proto::as_child<proto_domain>(a) \
             }; \
             return proto_domain()(that); \
@@ -413,10 +400,12 @@
         /**/
 
     #define BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST() \
- BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(1)
+ BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(BOOST_PROTO_CONST) \
+ /**/
 
     #define BOOST_PROTO_EXTENDS_SUBSCRIPT_NON_CONST() \
- BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(0)
+ BOOST_PROTO_EXTENDS_SUBSCRIPT_IMPL_(BOOST_PP_EMPTY) \
+ /**/
 
     #define BOOST_PROTO_EXTENDS_SUBSCRIPT() \
         BOOST_PROTO_EXTENDS_SUBSCRIPT_CONST() \
@@ -446,18 +435,18 @@
     #ifndef BOOST_NO_VARIADIC_TEMPLATES
         #define BOOST_PROTO_EXTENDS_FUNCTION_CONST() \
             BOOST_PROTO_EXTENDS_FUNCTION_() \
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(1) \
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) \
             /**/
 
         #define BOOST_PROTO_EXTENDS_FUNCTION_NON_CONST() \
             BOOST_PROTO_EXTENDS_FUNCTION_() \
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(0) \
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PP_EMPTY) \
             /**/
 
         #define BOOST_PROTO_EXTENDS_FUNCTION() \
             BOOST_PROTO_EXTENDS_FUNCTION_() \
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(0) \
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(1) \
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PP_EMPTY) \
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) \
             /**/
     #else
         #define BOOST_PROTO_EXTENDS_FUNCTION_CONST() \
@@ -510,9 +499,6 @@
         BOOST_PROTO_EXTENDS_COPY_ASSIGN_(Derived, BOOST_PP_EMPTY) \
         /**/
 
- /// INTERNAL ONLY
- #define BOOST_PROTO_TYPENAME() typename
-
     namespace exprns_
     {
         /// \brief Empty type to be used as a dummy template parameter of
@@ -576,7 +562,7 @@
             BOOST_PROTO_EXTENDS_FUNCTION_()
 
         #ifndef BOOST_NO_VARIADIC_TEMPLATES
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(1)
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST)
         #else
             /// INTERNAL ONLY
             ///
@@ -620,8 +606,8 @@
             BOOST_PROTO_EXTENDS_FUNCTION_()
 
         #ifndef BOOST_NO_VARIADIC_TEMPLATES
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(0)
- BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(1)
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PP_EMPTY)
+ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST)
         #else
 
             /// 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