$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: eric_at_[hidden]
Date: 2007-12-09 22:31:02
Author: eric_niebler
Date: 2007-12-09 22:31:01 EST (Sun, 09 Dec 2007)
New Revision: 41950
URL: http://svn.boost.org/trac/boost/changeset/41950
Log:
consistent handling of array terminals in proto::matches
Text files modified: 
   branches/proto/v3/boost/xpressive/proto/matches.hpp     |    35 +++++++++++++++++------                 
   branches/proto/v3/boost/xpressive/proto/traits.hpp      |    58 +++++++++++++++------------------------ 
   branches/proto/v3/libs/xpressive/proto/test/matches.cpp |    12 ++++++-                                 
   3 files changed, 57 insertions(+), 48 deletions(-)
Modified: branches/proto/v3/boost/xpressive/proto/matches.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/matches.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/matches.hpp	2007-12-09 22:31:01 EST (Sun, 09 Dec 2007)
@@ -79,6 +79,26 @@
               : Head
             {};
 
+            template<typename T, typename U>
+            struct array_matches
+              : mpl::false_
+            {};
+
+            template<typename T, std::size_t M>
+            struct array_matches<T[M], T *>
+              : mpl::true_
+            {};
+
+            template<typename T, std::size_t M>
+            struct array_matches<T[M], T const *>
+              : mpl::true_
+            {};
+
+            template<typename T, std::size_t M>
+            struct array_matches<T[M], T[proto::N]>
+              : mpl::true_
+            {};
+
             template<typename T, typename U
                 BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<U>::value)
             >
@@ -121,6 +141,11 @@
               : mpl::true_
             {};
 
+            template<typename T, std::size_t M, typename U>
+            struct lambda_matches<T[M], U BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+              : array_matches<T[M], U>
+            {};
+
             // How terminal_matches<> handles references and cv-qualifiers.
             // The cv and ref matter *only* if the grammar has a top-level ref.
             //
@@ -160,16 +185,6 @@
                 >
             {};
 
-            template<typename T, std::size_t M>
-            struct terminal_matches<T(&)[M], T(&)[proto::N]>
-              : mpl::true_
-            {};
-
-            template<typename T, std::size_t M>
-            struct terminal_matches<T(&)[M], T *>
-              : mpl::true_
-            {};
-
             template<typename T>
             struct terminal_matches<T, T>
               : mpl::true_
Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp	2007-12-09 22:31:01 EST (Sun, 09 Dec 2007)
@@ -415,8 +415,8 @@
         struct as_expr
         {
             typedef typename mpl::if_<
-                mpl::or_<is_array<UNCVREF(T)>, is_function<UNCVREF(T)> >
-              , REF(T)
+                is_function<UNREF(T)>
+              , T
               , UNCVREF(T)
             >::type value_type;
 
@@ -456,6 +456,7 @@
         {
             typedef expr<tag::terminal, term<CVREF(T) > > expr_type;
             typedef typename Domain::template apply<expr_type>::type type;
+
             static type call(CVREF(T) t)
             {
                 return Domain::make(expr_type::make(t));
@@ -466,6 +467,7 @@
         struct as_arg<T, Domain, typename T::proto_is_expr_>
         {
             typedef T const &type;
+
             static T const &call(T const &t)
             {
                 return t;
@@ -476,13 +478,14 @@
         struct as_arg<T &, Domain, typename T::proto_is_expr_>
         {
             typedef T &type;
+
             static T &call(T &t)
             {
                 return t;
             }
         };
 
-        template<typename T, typename _>
+        template<typename T, typename EnableIf>
         struct is_expr
           : mpl::false_
         {};
@@ -503,40 +506,40 @@
     {
 
         template<typename Domain>
-        struct as_expr
+        struct as_arg
         {
             template<typename Sig>
             struct result {};
 
             template<typename This, typename T>
             struct result<This(T)>
-              : result_of::as_expr<T, Domain>
+              : result_of::as_arg<T, Domain>
             {};
 
             template<typename T>
-            typename result_of::as_expr<T, Domain>::type
+            typename result_of::as_arg<T, Domain>::type
             operator ()(T &&t) const
             {
-                return result_of::as_expr<T, Domain>::call(t);
+                return result_of::as_arg<T, Domain>::call(t);
             }
         };
 
         template<typename Domain>
-        struct as_arg
+        struct as_expr
         {
             template<typename Sig>
             struct result {};
 
             template<typename This, typename T>
             struct result<This(T)>
-              : result_of::as_arg<T, Domain>
+              : result_of::as_expr<T, Domain>
             {};
 
             template<typename T>
-            typename result_of::as_arg<T, Domain>::type
+            typename result_of::as_expr<T, Domain>::type
             operator ()(T &&t) const
             {
-                return result_of::as_arg<T, Domain>::call(t);
+                return result_of::as_expr<T, Domain>::call(t);
             }
         };
 
@@ -566,34 +569,17 @@
             }
         };
 
-        //template<typename N>
-        //struct arg
-        //{
-        //    template<typename Sig>
-        //    struct result {};
-
-        //    template<typename This, typename Expr>
-        //    struct result<This(Expr)>
-        //      : result_of::arg<typename detail::remove_cv_ref<Expr>::type, N>
-        //    {};
-
-        //    template<typename Expr>
-        //    typename result_of::arg<Expr, N>::reference operator ()(Expr &expr) const
-        //    {
-        //        return result_of::arg<Expr, N>::call(expr);
-        //    }
-
-        //    template<typename Expr>
-        //    typename result_of::arg<Expr, N>::const_reference operator ()(Expr const &expr) const
-        //    {
-        //        return result_of::arg<Expr, N>::call(expr);
-        //    }
-        //};
+        template<typename N>
+        struct arg
+          : arg_c<N::value>
+        {};
 
-        struct left : arg_c<0>
+        struct left
+          : arg_c<0>
         {};
 
-        struct right : arg_c<1>
+        struct right
+          : arg_c<1>
         {};
 
     }
Modified: branches/proto/v3/libs/xpressive/proto/test/matches.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto/test/matches.cpp	(original)
+++ branches/proto/v3/libs/xpressive/proto/test/matches.cpp	2007-12-09 22:31:01 EST (Sun, 09 Dec 2007)
@@ -156,11 +156,19 @@
 
     assert_matches< terminal<char const (&)[6]> >( lit("hello") );
     assert_matches< terminal<char const (&)[6]> >( as_arg("hello") );
-    assert_matches< terminal<char const (&)[6]> >( as_expr("hello") );
+    assert_not_matches< terminal<char const (&)[6]> >( as_expr("hello") );
+
+    assert_matches< terminal<char [6]> >( lit("hello") );
+    assert_matches< terminal<char [6]> >( as_arg("hello") );
+    assert_matches< terminal<char [6]> >( as_expr("hello") );
 
     assert_matches< terminal<char const (&)[N]> >( lit("hello") );
     assert_matches< terminal<char const (&)[N]> >( as_arg("hello") );
-    assert_matches< terminal<char const (&)[N]> >( as_expr("hello") );
+    assert_not_matches< terminal<char const (&)[N]> >( as_expr("hello") );
+
+    assert_matches< terminal<char [N]> >( lit("hello") );
+    assert_matches< terminal<char [N]> >( as_arg("hello") );
+    assert_matches< terminal<char [N]> >( as_expr("hello") );
 
     assert_matches< terminal<std::string> >( lit(std::string("hello")) );
     assert_matches< terminal<std::string> >( as_arg(std::string("hello")) );