Hi,

I recently discovered a behavior which i find quite odd:
proto::matches<Expression, Grammar>::type fails when Expression is not a proto expression. I would have expected that it just returns false in this case. What am I missing. Patch is attached for what i think would be a better behavior of that meta function.

Regards,

Thomas
Index: boost/proto/matches.hpp
===================================================================
--- boost/proto/matches.hpp     (revision 81703)
+++ boost/proto/matches.hpp     (working copy)
@@ -500,7 +500,7 @@
     ///     <tt>[0,n)</tt>, \c Ax and \c Bx are types
     ///     such that \c Ax lambda-matches \c Bx
     template<typename Expr, typename Grammar>
-    struct matches
+    struct matches<Expr, Grammar, typename Expr::proto_is_expr_>
       : detail::matches_<
             typename Expr::proto_derived_expr
           , typename Expr::proto_grammar
@@ -511,13 +511,18 @@
     /// INTERNAL ONLY
     ///
     template<typename Expr, typename Grammar>
-    struct matches<Expr &, Grammar>
+    struct matches<Expr &, Grammar, typename Expr::proto_is_expr_>
       : detail::matches_<
             typename Expr::proto_derived_expr
           , typename Expr::proto_grammar
           , typename Grammar::proto_grammar
         >
     {};
+    
+    template<typename Expr, typename Grammar, typename Enable>
+    struct matches
+      : mpl::false_
+    {};
 
     /// \brief A wildcard grammar element that matches any expression,
     /// and a transform that returns the current expression unchanged.
Index: boost/proto/proto_fwd.hpp
===================================================================
--- boost/proto/proto_fwd.hpp   (revision 81703)
+++ boost/proto/proto_fwd.hpp   (working copy)
@@ -521,7 +521,7 @@
     template<typename T, typename Void = void>
     struct domain_of;
 
-    template<typename Expr, typename Grammar>
+    template<typename Expr, typename Grammar, typename Enable = void>
     struct matches;
 
     // Generic expression metafunctions and

_______________________________________________
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto

Reply via email to