|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-12-17 14:51:51
Author: eric_niebler
Date: 2007-12-17 14:51:50 EST (Mon, 17 Dec 2007)
New Revision: 42131
URL: http://svn.boost.org/trac/boost/changeset/42131
Log:
port is_callable to c++03
Added:
branches/proto/v3/boost/xpressive/proto/detail/is_callable.hpp (contents, props changed)
Text files modified:
branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp | 6 ++--
branches/proto/v3/boost/xpressive/proto/traits.hpp | 59 ---------------------------------------
2 files changed, 4 insertions(+), 61 deletions(-)
Modified: branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp 2007-12-17 14:51:50 EST (Mon, 17 Dec 2007)
@@ -55,7 +55,7 @@
>
>
{
- #define TMP(Z, N, DATA) typename boost::result_of<G##N(UNCVREF(E##N), S, V)>::type
+ #define TMP(Z, N, DATA) typename boost::result_of<G##N(E##N, S, V)>::type
typedef typename cat_args<
args<BOOST_PP_ENUM(BOOST_PROTO_MAX_ARITY, TMP, ~) >
, typename apply_args<args<ERest...>, S, V, typename pad_args<GRest...>::type>::type
@@ -73,10 +73,10 @@
, apply_args<args<ERest...>, S, V, typename pad_args<GRest...>::type>
::call(a BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP0, ~), s, v)
BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP2, ~);
+ return that;
#undef TMP0
#undef TMP1
#undef TMP2
- return that;
}
};
@@ -127,7 +127,7 @@
>
>
{
- #define TMP(Z, N, DATA) typename boost::result_of<G##N(UNCVREF(E##N), S, V)>::type
+ #define TMP(Z, N, DATA) typename boost::result_of<G##N(E##N, S, V)>::type
typedef args<BOOST_PP_ENUM(BOOST_PP_ITERATION(), TMP, ~)> type;
#undef TMP
Added: branches/proto/v3/boost/xpressive/proto/detail/is_callable.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/is_callable.hpp 2007-12-17 14:51:50 EST (Mon, 17 Dec 2007)
@@ -0,0 +1,90 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file is_callable.hpp
+ /// Definintion of detail::is_callable_
+ //
+ // Copyright 2007 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)
+
+ #ifndef BOOST_PROTO_DETAIL_IS_CALLABLE_HPP_EAN_11_07_2007
+ #define BOOST_PROTO_DETAIL_IS_CALLABLE_HPP_EAN_11_07_2007
+
+ #include <boost/mpl/bool.hpp>
+ #include <boost/type_traits.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+
+ namespace boost { namespace proto
+ {
+ namespace detail
+ {
+
+ template<typename T, typename EnableIf = void>
+ struct is_callable2_
+ : mpl::false_
+ {};
+
+ template<typename T>
+ struct is_callable2_<T, typename T::proto_is_callable_>
+ : mpl::true_
+ {};
+
+ template<typename T>
+ struct is_callable_
+ : is_callable2_<T>
+ {};
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<typename... Args>
+ struct back;
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Rest>
+ struct back<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...>
+ : back<Rest...>
+ {};
+
+ // TODO when gcc #33965 is fixed, change the idiom to
+ // template<typename X, bool IsTransform = true> struct my_transform {...};
+ template<
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename BOOST_PP_INTERCEPT), typename...> class T
+ , BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)
+ , typename... Rest
+ >
+ struct is_callable_<T<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Rest...> >
+ : is_same<typename back<Rest...>::type, callable>
+ {};
+ #endif
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/is_callable.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+ struct back<BOOST_PP_ENUM_PARAMS(N, A)>
+ {
+ typedef BOOST_PP_CAT(A, BOOST_PP_DEC(N)) type;
+ };
+ #endif
+
+ // TODO when gcc #33965 is fixed, change the idiom to
+ // template<typename X, bool IsTransform = true> struct my_transform {...};
+ template<
+ 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)> >
+ : is_same<BOOST_PP_CAT(A, BOOST_PP_DEC(N)), callable>
+ {};
+
+ #undef N
+
+#endif
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-17 14:51:50 EST (Mon, 17 Dec 2007)
@@ -14,6 +14,7 @@
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/args.hpp>
#include <boost/xpressive/proto/detail/apply_args.hpp>
+#include <boost/xpressive/proto/detail/is_callable.hpp>
#include <boost/xpressive/proto/detail/define.hpp>
namespace boost { namespace proto
@@ -564,64 +565,6 @@
return result_of::as_arg<T, Domain>::call(t);
}
- namespace detail
- {
- template<typename... Args>
- struct back;
-
- template<typename A0>
- struct back<A0>
- {
- typedef A0 type;
- };
-
- template<typename A0, typename A1>
- struct back<A0, A1>
- {
- typedef A1 type;
- };
-
- template<typename A0, typename A1, typename A2>
- struct back<A0, A1, A2>
- {
- typedef A2 type;
- };
-
- template<typename A0, typename A1, typename A2, typename A3>
- struct back<A0, A1, A2, A3>
- {
- typedef A3 type;
- };
-
- template<typename A0, typename A1, typename A2, typename A3, typename... Rest>
- struct back<A0, A1, A2, A3, Rest...>
- : back<Rest...>
- {};
-
- template<typename T, typename EnableIf = void>
- struct is_callable2_
- : mpl::false_
- {};
-
- template<typename T>
- struct is_callable2_<T, typename T::proto_is_callable_>
- : mpl::true_
- {};
-
- template<typename T>
- struct is_callable_
- : is_callable2_<T>
- {};
-
- // TODO when gcc #33965 is fixed, change the idiom to
- // template<typename X, bool IsTransform = true> struct my_transform {...};
- template<template<typename...> class T, typename... Args>
- struct is_callable_<T<Args...> >
- : is_same<typename back<Args...>::type, callable>
- {};
-
- } // namespace detail
-
/// is_callable
///
template<typename T>
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