Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-29 15:09:18


Author: eric_niebler
Date: 2008-05-29 15:09:17 EDT (Thu, 29 May 2008)
New Revision: 45917
URL: http://svn.boost.org/trac/boost/changeset/45917

Log:
ugh, work around std::map::op[] strangeness
Text files modified:
   branches/proto/v4/boost/proto/context/default.hpp | 2
   branches/proto/v4/boost/proto/detail/decltype.hpp | 120 +++++++++++++++++++++++++++++++++++++++
   branches/proto/v4/boost/proto/transform/default.hpp | 2
   3 files changed, 121 insertions(+), 3 deletions(-)

Modified: branches/proto/v4/boost/proto/context/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/context/default.hpp (original)
+++ branches/proto/v4/boost/proto/context/default.hpp 2008-05-29 15:09:17 EDT (Thu, 29 May 2008)
@@ -243,7 +243,7 @@
                 typedef typename proto::result_of::eval<UNREF(e0), Context>::type r0;
                 typedef typename proto::result_of::eval<UNREF(e1), Context>::type r1;
             public:
- BOOST_PROTO_DECLTYPE_(proto::detail::make<r0>()[proto::detail::make<r1>()], result_type)
+ BOOST_PROTO_DECLTYPE_(proto::detail::make_subscriptable<r0>()[proto::detail::make<r1>()], result_type)
                 result_type operator ()(Expr &expr, Context &ctx) const
                 {
                     return proto::eval(proto::child_c<0>(expr), ctx)[proto::eval(proto::child_c<1>(expr), ctx)];

Modified: branches/proto/v4/boost/proto/detail/decltype.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/decltype.hpp (original)
+++ branches/proto/v4/boost/proto/detail/decltype.hpp 2008-05-29 15:09:17 EDT (Thu, 29 May 2008)
@@ -63,6 +63,62 @@
     namespace detail
     {
         ////////////////////////////////////////////////////////////////////////////////////////////
+ struct any
+ {
+ any(...);
+ any operator=(any);
+ any operator[](any);
+ #define M0(Z, N, DATA) any operator()(BOOST_PP_ENUM_PARAMS_Z(Z, N, any BOOST_PP_INTERCEPT));
+ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, ~)
+ #undef M0
+
+ operator int any::*();
+
+ any operator+();
+ any operator-();
+ any operator*();
+ any operator&();
+ any operator~();
+ any operator!();
+ any operator++();
+ any operator--();
+ any operator++(int);
+ any operator--(int);
+
+ any operator<<(any);
+ any operator>>(any);
+ any operator*(any);
+ any operator/(any);
+ any operator%(any);
+ any operator+(any);
+ any operator-(any);
+ any operator<(any);
+ any operator>(any);
+ any operator<=(any);
+ any operator>=(any);
+ any operator==(any);
+ any operator!=(any);
+ any operator||(any);
+ any operator&&(any);
+ any operator&(any);
+ any operator|(any);
+ any operator^(any);
+ any operator,(any);
+ any operator->*(any);
+
+ any operator<<=(any);
+ any operator>>=(any);
+ any operator*=(any);
+ any operator/=(any);
+ any operator%=(any);
+ any operator+=(any);
+ any operator-=(any);
+ any operator&=(any);
+ any operator|=(any);
+ any operator^=(any);
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
         template<typename T>
         struct as_mutable
         {
@@ -91,6 +147,68 @@
 
         ////////////////////////////////////////////////////////////////////////////////////////////
         template<typename T>
+ struct subscript_wrapper
+ : T
+ {
+ using T::operator[];
+ any operator[](any) const volatile;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ struct as_subscriptable
+ {
+ typedef
+ typename mpl::if_c<
+ is_class<T>::value
+ , subscript_wrapper<T>
+ , T
+ >::type
+ type;
+ };
+
+ template<typename T>
+ struct as_subscriptable<T const>
+ {
+ typedef
+ typename mpl::if_c<
+ is_class<T>::value
+ , subscript_wrapper<T> const
+ , T const
+ >::type
+ type;
+ };
+
+ template<typename T>
+ struct as_subscriptable<T &>
+ {
+ typedef
+ typename mpl::if_c<
+ is_class<T>::value
+ , subscript_wrapper<T> &
+ , T &
+ >::type
+ type;
+ };
+
+ template<typename T>
+ struct as_subscriptable<T const &>
+ {
+ typedef
+ typename mpl::if_c<
+ is_class<T>::value
+ , subscript_wrapper<T> const &
+ , T const &
+ >::type
+ type;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
+ typename as_subscriptable<T>::type make_subscriptable();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename T>
         char check_reference(T &);
 
         template<typename T>
@@ -100,7 +218,7 @@
         {
             using boost::get_pointer;
             void *(&get_pointer(...))[2];
-
+
             ////////////////////////////////////////////////////////////////////////////////////////////
             template<typename T>
             struct has_get_pointer

Modified: branches/proto/v4/boost/proto/transform/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/default.hpp (original)
+++ branches/proto/v4/boost/proto/transform/default.hpp 2008-05-29 15:09:17 EDT (Thu, 29 May 2008)
@@ -258,7 +258,7 @@
                 typedef typename Grammar::template impl<e1, State, Data>::result_type r1;
             public:
                 BOOST_PROTO_DECLTYPE_(
- proto::detail::make<r0>() [ proto::detail::make<r1>() ]
+ proto::detail::make_subscriptable<r0>() [ proto::detail::make<r1>() ]
                   , result_type
                 )
                 result_type operator ()(


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