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

Modified Files:
        vector.cpp 
Log Message:
add null_context, use in vector.cpp example

Index: vector.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/proto/example/vector.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vector.cpp  25 Jun 2007 05:40:42 -0000      1.1
+++ vector.cpp  25 Jun 2007 07:44:54 -0000      1.2
@@ -53,25 +53,33 @@
 // Here is an evaluation context that verifies that all the
 // vectors in an expression have the same size.
 struct VectorSizeCtx
-  : proto::callable_context< VectorSizeCtx const >
 {
-    typedef int result_type;
-
     VectorSizeCtx(std::size_t size)
       : size_(size)
     {}
 
+    // Unless this is a vector terminal, use the
+    // null evaluation context
+    template<typename Expr, typename Arg = typename 
proto::result_of::arg<Expr>::type>
+    struct eval
+      : proto::null_eval<Expr, VectorSizeCtx const>
+    {};
+
     // Index array terminals with our subscript. Everything
     // else will be handled by the default evaluation context.
-    template<typename T, typename A>
-    int operator()(proto::tag::terminal, std::vector<T, A> const &arr) const
+    template<typename Expr, typename T, typename A>
+    struct eval<Expr, std::vector<T, A> >
     {
-        if(this->size_ != arr.size())
+        typedef void result_type;
+
+        result_type operator()(Expr &expr, VectorSizeCtx const &ctx) const
         {
-            throw std::invalid_argument("LHS and RHS are not compatible");
+            if(ctx.size_ != proto::arg(expr).size())
+            {
+                throw std::invalid_argument("LHS and RHS are not compatible");
+            }
         }
-        return 0; // not used
-    }
+    };
 
     std::size_t size_;
 };


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to