Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18438/proto

Modified Files:
        expr.hpp 
Log Message:
make &(expr) implicitly convertible to Expr*

Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- expr.hpp    15 Feb 2007 18:38:04 -0000      1.24
+++ expr.hpp    13 Mar 2007 02:07:54 -0000      1.25
@@ -24,6 +24,7 @@
     #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
     #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
     #include <boost/utility/result_of.hpp>
+    #include <boost/utility/addressof.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
     #include <boost/xpressive/proto/ref.hpp>
     #include <boost/xpressive/proto/args.hpp>
@@ -53,6 +54,21 @@
         proto::unref(this->BOOST_PP_CAT(arg, n))\
         /**/
 
+        namespace detail
+        {
+            template<typename Tag, typename Arg>
+            struct address_of_hack
+            {
+                typedef address_of_hack type;
+            };
+
+            template<typename Expr>
+            struct address_of_hack<tag::address_of, ref<Expr> >
+            {
+                typedef Expr *type;
+            };
+        }
+
         namespace result_of
         {
         #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 
BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), <boost/xpressive/proto/detail/funop.hpp>))
@@ -108,6 +124,14 @@
                 expr that = {a0};
                 return that;
             }
+
+            // HACKHACK proto overloads operator&, which means that 
proto-ified objects
+            // cannot have their addresses taken, unless we use the following 
hack to
+            // make &x implicitly convertible to X*.
+            operator typename detail::address_of_hack<Tag, arg0_type>::type() 
const
+            {
+                return boost::addressof(this->arg0.expr);
+            }
         #endif
 
             template<BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), typename A)>


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to