Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71777 - in trunk/boost/proto: . detail detail/preprocessed transform
From: eric_at_[hidden]
Date: 2011-05-07 06:06:28


Author: eric_niebler
Date: 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
New Revision: 71777
URL: http://svn.boost.org/trac/boost/changeset/71777

Log:
remove dependency on BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING PP constant
Added:
   trunk/boost/proto/detail/template_arity.hpp (contents, props changed)
Text files modified:
   trunk/boost/proto/detail/deduce_domain.hpp | 6 ------
   trunk/boost/proto/detail/lambda_matches.hpp | 8 +-------
   trunk/boost/proto/detail/preprocessed/lambda_matches.hpp | 8 ++++----
   trunk/boost/proto/detail/preprocessed/traits.hpp | 10 +++++-----
   trunk/boost/proto/detail/traits.hpp | 6 +-----
   trunk/boost/proto/matches.hpp | 29 ++++++++---------------------
   trunk/boost/proto/proto_fwd.hpp | 11 +++++++++++
   trunk/boost/proto/traits.hpp | 5 ++---
   trunk/boost/proto/transform/make.hpp | 9 ++++-----
   9 files changed, 36 insertions(+), 56 deletions(-)

Modified: trunk/boost/proto/detail/deduce_domain.hpp
==============================================================================
--- trunk/boost/proto/detail/deduce_domain.hpp (original)
+++ trunk/boost/proto/detail/deduce_domain.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -37,12 +37,6 @@
     {
         namespace detail
         {
- template<int N>
- struct sized_type
- {
- typedef char (&type)[N];
- };
-
             template<typename Domain>
             struct domain_
               : domain_<typename Domain::proto_super_domain>

Modified: trunk/boost/proto/detail/lambda_matches.hpp
==============================================================================
--- trunk/boost/proto/detail/lambda_matches.hpp (original)
+++ trunk/boost/proto/detail/lambda_matches.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -1,8 +1,6 @@
 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
 
- #define BOOST_PROTO_LAMBDA_ARITY_PARAM BOOST_MPL_AUX_LAMBDA_ARITY_PARAM
     #include <boost/proto/detail/preprocessed/lambda_matches.hpp>
- #undef BOOST_PROTO_LAMBDA_ARITY_PARAM
 
 #elif !defined(BOOST_PP_IS_ITERATING)
 
@@ -14,8 +12,6 @@
 
     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/lambda_matches.hpp")
- #else
- #define BOOST_PROTO_LAMBDA_ARITY_PARAM BOOST_MPL_AUX_LAMBDA_ARITY_PARAM
     #endif
 
     ///////////////////////////////////////////////////////////////////////////////
@@ -36,8 +32,6 @@
 
     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
         #pragma wave option(output: null)
- #else
- #undef BOOST_PROTO_LAMBDA_ARITY_PARAM
     #endif
 
     #undef BOOST_PROTO_DEFINE_LAMBDA_MATCHES
@@ -54,7 +48,7 @@
     struct lambda_matches<
         T<BOOST_PP_ENUM_PARAMS(N, Expr)>
       , T<BOOST_PP_ENUM_PARAMS(N, Grammar)>
- BOOST_PROTO_LAMBDA_ARITY_PARAM(N)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)
>
       : BOOST_PP_CAT(and_, N)<
             BOOST_PROTO_DEFINE_LAMBDA_MATCHES(~, 0, ~)::value,

Modified: trunk/boost/proto/detail/preprocessed/lambda_matches.hpp
==============================================================================
--- trunk/boost/proto/detail/preprocessed/lambda_matches.hpp (original)
+++ trunk/boost/proto/detail/preprocessed/lambda_matches.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -13,7 +13,7 @@
     struct lambda_matches<
         T<Expr0 , Expr1>
       , T<Grammar0 , Grammar1>
- BOOST_PROTO_LAMBDA_ARITY_PARAM(2)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(2)
>
       : and_2<
             lambda_matches< Expr0 , Grammar0 >::value,
@@ -28,7 +28,7 @@
     struct lambda_matches<
         T<Expr0 , Expr1 , Expr2>
       , T<Grammar0 , Grammar1 , Grammar2>
- BOOST_PROTO_LAMBDA_ARITY_PARAM(3)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(3)
>
       : and_3<
             lambda_matches< Expr0 , Grammar0 >::value,
@@ -43,7 +43,7 @@
     struct lambda_matches<
         T<Expr0 , Expr1 , Expr2 , Expr3>
       , T<Grammar0 , Grammar1 , Grammar2 , Grammar3>
- BOOST_PROTO_LAMBDA_ARITY_PARAM(4)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(4)
>
       : and_4<
             lambda_matches< Expr0 , Grammar0 >::value,
@@ -58,7 +58,7 @@
     struct lambda_matches<
         T<Expr0 , Expr1 , Expr2 , Expr3 , Expr4>
       , T<Grammar0 , Grammar1 , Grammar2 , Grammar3 , Grammar4>
- BOOST_PROTO_LAMBDA_ARITY_PARAM(5)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(5)
>
       : and_5<
             lambda_matches< Expr0 , Grammar0 >::value,

Modified: trunk/boost/proto/detail/preprocessed/traits.hpp
==============================================================================
--- trunk/boost/proto/detail/preprocessed/traits.hpp (original)
+++ trunk/boost/proto/detail/preprocessed/traits.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -141,7 +141,7 @@
                 template<typename> class T
               , typename A0
>
- struct is_callable_<T<A0> BOOST_PROTO_LAMBDA_ARITY_PARAM(1)>
+ struct is_callable_<T<A0> BOOST_PROTO_TEMPLATE_ARITY_PARAM(1)>
               : is_same<A0, callable>
             {};
         }
@@ -281,7 +281,7 @@
                 template<typename , typename> class T
               , typename A0 , typename A1
>
- struct is_callable_<T<A0 , A1> BOOST_PROTO_LAMBDA_ARITY_PARAM(2)>
+ struct is_callable_<T<A0 , A1> BOOST_PROTO_TEMPLATE_ARITY_PARAM(2)>
               : is_same<A1, callable>
             {};
         }
@@ -421,7 +421,7 @@
                 template<typename , typename , typename> class T
               , typename A0 , typename A1 , typename A2
>
- struct is_callable_<T<A0 , A1 , A2> BOOST_PROTO_LAMBDA_ARITY_PARAM(3)>
+ struct is_callable_<T<A0 , A1 , A2> BOOST_PROTO_TEMPLATE_ARITY_PARAM(3)>
               : is_same<A2, callable>
             {};
         }
@@ -561,7 +561,7 @@
                 template<typename , typename , typename , typename> class T
               , typename A0 , typename A1 , typename A2 , typename A3
>
- struct is_callable_<T<A0 , A1 , A2 , A3> BOOST_PROTO_LAMBDA_ARITY_PARAM(4)>
+ struct is_callable_<T<A0 , A1 , A2 , A3> BOOST_PROTO_TEMPLATE_ARITY_PARAM(4)>
               : is_same<A3, callable>
             {};
         }
@@ -692,7 +692,7 @@
                 template<typename , typename , typename , typename , typename> class T
               , typename A0 , typename A1 , typename A2 , typename A3 , typename A4
>
- struct is_callable_<T<A0 , A1 , A2 , A3 , A4> BOOST_PROTO_LAMBDA_ARITY_PARAM(5)>
+ struct is_callable_<T<A0 , A1 , A2 , A3 , A4> BOOST_PROTO_TEMPLATE_ARITY_PARAM(5)>
               : is_same<A4, callable>
             {};
         }

Added: trunk/boost/proto/detail/template_arity.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/proto/detail/template_arity.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -0,0 +1,88 @@
+#ifndef BOOST_PP_IS_ITERATING
+
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file template_arity.hpp
+ /// Replace all nodes stored by reference by nodes stored by value.
+ //
+ // Copyright 2011 Eric Niebler. Distributed under the Boost
+ // Software License, Version 1.0. (See accompanying file
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ //
+ // This file is based on a similar one in MPL from Aleksey Gurtovoy.
+
+ #ifndef BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
+ #define BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
+
+ #ifdef BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
+
+ #include <boost/preprocessor/cat.hpp>
+ #include <boost/preprocessor/inc.hpp>
+ #include <boost/preprocessor/iteration/iterate.hpp>
+ #include <boost/preprocessor/repetition/enum_params.hpp>
+ #include <boost/mpl/int.hpp>
+ #include <boost/proto/proto_fwd.hpp>
+
+ // When generating the preprocessed headers, leave this workaround in by
+ // simply not defining it.
+ #if !defined(__WAVE__) || !defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
+ #define BOOST_PROTO_TEMPLATE_ARITY_PARAM(param) , param
+ #endif
+
+ namespace boost { namespace proto { namespace detail
+ {
+ sized_type<1>::type arity_helper(...);
+
+ #define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/template_arity.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ template<typename F, int N, int Size>
+ struct template_arity_impl2
+ : mpl::int_<Size - 1>
+ {};
+
+ template<typename F, int N = BOOST_PROTO_MAX_ARITY>
+ struct template_arity
+ : template_arity_impl2<
+ F
+ , N
+ , sizeof(detail::arity_helper((F **)0, (mpl::int_<N> *)0))
+ >
+ {};
+
+ template<typename F, int N>
+ struct template_arity_impl2<F, N, 1>
+ : template_arity<F, N-1>
+ {};
+
+ template<typename F>
+ struct template_arity_impl2<F, 0, 1>
+ : mpl::int_<-1>
+ {};
+
+ }}}
+
+ #else
+
+ // When generating the preprocessed headers, leave this workaround in by
+ // simply not defining it.
+ #if !defined(__WAVE__) || !defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
+ #define BOOST_PROTO_TEMPLATE_ARITY_PARAM(param)
+ #endif
+
+ #endif // BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
+ #endif // BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<
+ template<BOOST_PP_ENUM_PARAMS(N, typename P)> class F
+ , BOOST_PP_ENUM_PARAMS(N, typename T)
+ >
+ sized_type<BOOST_PP_INC(N)>::type arity_helper(F<BOOST_PP_ENUM_PARAMS(N, T)> **, mpl::int_<N> *);
+
+ #undef N
+
+#endif // BOOST_PP_IS_ITERATING

Modified: trunk/boost/proto/detail/traits.hpp
==============================================================================
--- trunk/boost/proto/detail/traits.hpp (original)
+++ trunk/boost/proto/detail/traits.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -1,10 +1,8 @@
 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
 
- #define BOOST_PROTO_LAMBDA_ARITY_PARAM BOOST_MPL_AUX_LAMBDA_ARITY_PARAM
     #define BOOST_PROTO_STATIC_ASSERT BOOST_STATIC_ASSERT
     #include <boost/proto/detail/preprocessed/traits.hpp>
     #undef BOOST_PROTO_STATIC_ASSERT
- #undef BOOST_PROTO_LAMBDA_ARITY_PARAM
 
 #elif !defined(BOOST_PP_IS_ITERATING)
 
@@ -16,7 +14,6 @@
     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/traits.hpp")
     #else
- #define BOOST_PROTO_LAMBDA_ARITY_PARAM BOOST_MPL_AUX_LAMBDA_ARITY_PARAM
         #define BOOST_PROTO_STATIC_ASSERT BOOST_STATIC_ASSERT
     #endif
 
@@ -40,7 +37,6 @@
         #pragma wave option(output: null)
     #else
         #undef BOOST_PROTO_STATIC_ASSERT
- #undef BOOST_PROTO_LAMBDA_ARITY_PARAM
     #endif
 
     #undef BOOST_PROTO_CHILD
@@ -140,7 +136,7 @@
                 template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class T
               , BOOST_PP_ENUM_PARAMS(N, typename A)
>
- struct is_callable_<T<BOOST_PP_ENUM_PARAMS(N, A)> BOOST_PROTO_LAMBDA_ARITY_PARAM(N)>
+ struct is_callable_<T<BOOST_PP_ENUM_PARAMS(N, A)> BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)>
               : is_same<BOOST_PP_CAT(A, BOOST_PP_DEC(N)), callable>
             {};
         }

Modified: trunk/boost/proto/matches.hpp
==============================================================================
--- trunk/boost/proto/matches.hpp (original)
+++ trunk/boost/proto/matches.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -29,8 +29,7 @@
 #include <boost/config.hpp>
 #include <boost/mpl/logical.hpp>
 #include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/aux_/template_arity.hpp>
-#include <boost/mpl/aux_/lambda_arity_param.hpp>
+#include <boost/proto/detail/template_arity.hpp>
 #include <boost/utility/enable_if.hpp>
 #if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
 #include <boost/type_traits/is_array.hpp>
@@ -44,18 +43,6 @@
 #include <boost/proto/transform/when.hpp>
 #include <boost/proto/transform/impl.hpp>
 
-// Some compilers (like GCC) need extra help figuring out a template's arity.
-// I use MPL's BOOST_MPL_AUX_LAMBDA_ARITY_PARAM() macro to disambiguate, which
-// which is controlled by the BOOST_MPL_LIMIT_METAFUNCTION_ARITY macro. If
-// You define BOOST_PROTO_MAX_ARITY to be greater than
-// BOOST_MPL_LIMIT_METAFUNCTION_ARITY on these compilers, things don't work.
-// You must define BOOST_MPL_LIMIT_METAFUNCTION_ARITY to be greater.
-#ifdef BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
-# if BOOST_PROTO_MAX_ARITY > BOOST_MPL_LIMIT_METAFUNCTION_ARITY
-# error BOOST_MPL_LIMIT_METAFUNCTION_ARITY must be at least as large as BOOST_PROTO_MAX_ARITY
-# endif
-#endif
-
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma warning(push)
 # pragma warning(disable:4305) // 'specialization' : truncation from 'const int' to 'bool'
@@ -99,39 +86,39 @@
         {};
 
         template<typename T, typename U
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<U>::value)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(long Arity = detail::template_arity<U>::value)
>
         struct lambda_matches
           : mpl::false_
         {};
 
         template<typename T>
- struct lambda_matches<T, proto::_ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ struct lambda_matches<T, proto::_ BOOST_PROTO_TEMPLATE_ARITY_PARAM(-1)>
           : mpl::true_
         {};
 
         template<typename T>
- struct lambda_matches<T, T BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ struct lambda_matches<T, T BOOST_PROTO_TEMPLATE_ARITY_PARAM(-1)>
           : mpl::true_
         {};
 
         template<typename T, std::size_t M, typename U>
- struct lambda_matches<T[M], U BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ struct lambda_matches<T[M], U BOOST_PROTO_TEMPLATE_ARITY_PARAM(-1)>
           : array_matches<T[M], U>
         {};
 
         template<typename T, std::size_t M>
- struct lambda_matches<T[M], _ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ struct lambda_matches<T[M], _ BOOST_PROTO_TEMPLATE_ARITY_PARAM(-1)>
           : mpl::true_
         {};
 
         template<typename T, std::size_t M>
- struct lambda_matches<T[M], T[M] BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ struct lambda_matches<T[M], T[M] BOOST_PROTO_TEMPLATE_ARITY_PARAM(-1)>
           : mpl::true_
         {};
 
         template<template<typename> class T, typename Expr0, typename Grammar0>
- struct lambda_matches<T<Expr0>, T<Grammar0> BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(1) >
+ struct lambda_matches<T<Expr0>, T<Grammar0> BOOST_PROTO_TEMPLATE_ARITY_PARAM(1) >
           : lambda_matches<Expr0, Grammar0>
         {};
 

Modified: trunk/boost/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/proto/proto_fwd.hpp (original)
+++ trunk/boost/proto/proto_fwd.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -24,6 +24,7 @@
 #include <boost/mpl/long.hpp>
 #include <boost/type_traits/remove_const.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/mpl/aux_/config/ttp.hpp>
 
 #ifndef BOOST_PROTO_MAX_ARITY
 # define BOOST_PROTO_MAX_ARITY 5
@@ -97,6 +98,10 @@
 # define BOOST_PROTO_RESULT_OF boost::tr1_result_of
 #endif
 
+#ifdef BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
+# define BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
+#endif
+
 namespace boost { namespace proto
 {
     namespace detail
@@ -104,6 +109,12 @@
         typedef char yes_type;
         typedef char (&no_type)[2];
 
+ template<int N>
+ struct sized_type
+ {
+ typedef char (&type)[N];
+ };
+
         struct dont_care;
         struct undefined; // leave this undefined
         struct not_a_valid_type;

Modified: trunk/boost/proto/traits.hpp
==============================================================================
--- trunk/boost/proto/traits.hpp (original)
+++ trunk/boost/proto/traits.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -23,8 +23,7 @@
 #include <boost/preprocessor/arithmetic/sub.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/mpl/bool.hpp>
-#include <boost/mpl/aux_/template_arity.hpp>
-#include <boost/mpl/aux_/lambda_arity_param.hpp>
+#include <boost/proto/detail/template_arity.hpp>
 #include <boost/type_traits/is_pod.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/type_traits/add_const.hpp>
@@ -61,7 +60,7 @@
           : mpl::true_
         {};
 
- template<typename T BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<T>::value)>
+ template<typename T BOOST_PROTO_TEMPLATE_ARITY_PARAM(long Arity = boost::proto::detail::template_arity<T>::value)>
         struct is_callable_
           : is_callable2_<T>
         {};

Modified: trunk/boost/proto/transform/make.hpp
==============================================================================
--- trunk/boost/proto/transform/make.hpp (original)
+++ trunk/boost/proto/transform/make.hpp 2011-05-07 06:06:26 EDT (Sat, 07 May 2011)
@@ -24,8 +24,7 @@
     #include <boost/preprocessor/arithmetic/inc.hpp>
     #include <boost/mpl/and.hpp>
     #include <boost/mpl/aux_/has_type.hpp>
- #include <boost/mpl/aux_/template_arity.hpp>
- #include <boost/mpl/aux_/lambda_arity_param.hpp>
+ #include <boost/proto/detail/template_arity.hpp>
     #include <boost/utility/result_of.hpp>
     #include <boost/proto/proto_fwd.hpp>
     #include <boost/proto/traits.hpp>
@@ -72,7 +71,7 @@
             template<
                 typename R
               , typename Expr, typename State, typename Data
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<R>::value)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(long Arity = detail::template_arity<R>::value)
>
             struct make_
             {
@@ -305,7 +304,7 @@
             struct make_<
                 R<BOOST_PP_ENUM_PARAMS(N, A)>
               , Expr, State, Data
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)
>
               : nested_type_if<R<BOOST_PP_ENUM(N, TMP1, ~)>, (BOOST_PP_REPEAT(N, TMP2, ~) false)>
             {};
@@ -318,7 +317,7 @@
             struct make_<
                 noinvoke<R<BOOST_PP_ENUM_PARAMS(N, A)> >
               , Expr, State, Data
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(1)
+ BOOST_PROTO_TEMPLATE_ARITY_PARAM(1)
>
             {
                 typedef R<BOOST_PP_ENUM(N, TMP1, ~)> type;


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