gcc-4.4 doesn't have robust enough support for sfinae-for-expressions

[SVN r80654]
This commit is contained in:
Eric Niebler 2012-09-23 01:11:00 +00:00
parent 1cfe3145b4
commit 7148d6c95e
2 changed files with 41 additions and 37 deletions

View File

@ -56,37 +56,37 @@ struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
namespace detail { namespace detail {
#ifdef BOOST_NO_SFINAE_EXPR #ifdef BOOST_RESULT_OF_NO_SFINAE_EXPR
template<typename F> template<typename F>
struct BOOST_PP_CAT(result_of_is_callable_fun_2_, BOOST_PP_ITERATION()); struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION());
template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)> template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
struct BOOST_PP_CAT(result_of_is_callable_fun_2_, BOOST_PP_ITERATION())<R(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))> { struct BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<R(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))> {
R operator()(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const; R operator()(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const;
typedef result_of_private_type const &(*pfn_t)(...); typedef result_of_private_type const &(*pfn_t)(...);
operator pfn_t() const volatile; operator pfn_t() const volatile;
}; };
template<typename F> template<typename F>
struct BOOST_PP_CAT(result_of_is_callable_fun_, BOOST_PP_ITERATION()); struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION());
template<typename F> template<typename F>
struct BOOST_PP_CAT(result_of_is_callable_fun_, BOOST_PP_ITERATION())<F *> struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F *>
: BOOST_PP_CAT(result_of_is_callable_fun_2_, BOOST_PP_ITERATION())<F> : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
{}; {};
template<typename F> template<typename F>
struct BOOST_PP_CAT(result_of_is_callable_fun_, BOOST_PP_ITERATION())<F &> struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F &>
: BOOST_PP_CAT(result_of_is_callable_fun_2_, BOOST_PP_ITERATION())<F> : BOOST_PP_CAT(result_of_callable_fun_2_, BOOST_PP_ITERATION())<F>
{}; {};
template<typename F> template<typename F>
struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION()) struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())
: mpl::eval_if< : mpl::eval_if<
is_class<typename remove_reference<F>::type>, is_class<typename remove_reference<F>::type>,
result_of_wrap_callable<result_of_callable_class, F>, result_of_wrap_callable_class<F>,
mpl::identity<BOOST_PP_CAT(result_of_is_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<F>::type> > mpl::identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<F>::type> >
> >
{}; {};
@ -119,7 +119,7 @@ struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), fal
) type; ) type;
}; };
#else // BOOST_NO_SFINAE_EXPR #else // BOOST_RESULT_OF_NO_SFINAE_EXPR
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)> template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
@ -135,7 +135,7 @@ struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
) type; ) type;
}; };
#endif // BOOST_NO_SFINAE_EXPR #endif // BOOST_RESULT_OF_NO_SFINAE_EXPR
} // namespace detail } // namespace detail

View File

@ -54,6 +54,10 @@
# endif # endif
#endif #endif
#if defined(BOOST_NO_SFINAE_EXPR) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ < 5)
# define BOOST_RESULT_OF_NO_SFINAE_EXPR
#endif
namespace boost { namespace boost {
template<typename F> struct result_of; template<typename F> struct result_of;
@ -66,7 +70,7 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl; template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
#ifdef BOOST_NO_SFINAE_EXPR #ifdef BOOST_RESULT_OF_NO_SFINAE_EXPR
template<typename T> T result_of_decay(T); template<typename T> T result_of_decay(T);
@ -75,13 +79,6 @@ struct result_of_private_type
result_of_private_type const &operator,(int) const; result_of_private_type const &operator,(int) const;
}; };
template<typename C>
struct result_of_callable_class : C {
result_of_callable_class();
typedef result_of_private_type const &(*pfn_t)(...);
operator pfn_t() const volatile;
};
typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1 typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1
typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2 typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2
@ -90,34 +87,41 @@ result_of_no_type result_of_is_private_type(T const &);
result_of_yes_type result_of_is_private_type(result_of_private_type const &); result_of_yes_type result_of_is_private_type(result_of_private_type const &);
template<template<typename> class Wrapper, typename C> template<typename C>
struct result_of_wrap_callable { struct result_of_callable_class : C {
typedef Wrapper<C> type; result_of_callable_class();
typedef result_of_private_type const &(*pfn_t)(...);
operator pfn_t() const volatile;
}; };
template<template<typename> class Wrapper, typename C> template<typename C>
struct result_of_wrap_callable<Wrapper, C &> { struct result_of_wrap_callable_class {
typedef typename result_of_wrap_callable<Wrapper, C>::type &type; typedef result_of_callable_class<C> type;
}; };
template<template<typename> class Wrapper, typename C> template<typename C>
struct result_of_wrap_callable<Wrapper, C const> { struct result_of_wrap_callable_class<C const> {
typedef typename result_of_wrap_callable<Wrapper, C>::type const type; typedef result_of_callable_class<C> const type;
}; };
template<template<typename> class Wrapper, typename C> template<typename C>
struct result_of_wrap_callable<Wrapper, C volatile> { struct result_of_wrap_callable_class<C volatile> {
typedef typename result_of_wrap_callable<Wrapper, C>::type volatile type; typedef result_of_callable_class<C> volatile type;
}; };
template<template<typename> class Wrapper, typename C> template<typename C>
struct result_of_wrap_callable<Wrapper, C const volatile> { struct result_of_wrap_callable_class<C const volatile> {
typedef typename result_of_wrap_callable<Wrapper, C>::type const volatile type; typedef result_of_callable_class<C> const volatile type;
};
template<typename C>
struct result_of_wrap_callable_class<C &> {
typedef typename result_of_wrap_callable_class<C>::type &type;
}; };
template<typename F, bool TestCallability = true> struct cpp0x_result_of_impl; template<typename F, bool TestCallability = true> struct cpp0x_result_of_impl;
#else // BOOST_NO_SFINAE_EXPR #else // BOOST_RESULT_OF_NO_SFINAE_EXPR
template<typename T> template<typename T>
struct result_of_always_void struct result_of_always_void
@ -127,7 +131,7 @@ struct result_of_always_void
template<typename F, typename Enable = void> struct cpp0x_result_of_impl {}; template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
#endif // BOOST_NO_SFINAE_EXPR #endif // BOOST_RESULT_OF_NO_SFINAE_EXPR
template<typename F> template<typename F>
struct result_of_void_impl struct result_of_void_impl