// C++11 type_traits -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
-// Free Software Foundation, Inc.
+// Copyright (C) 2007-2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
template<typename _Signature>
class result_of;
+ // sfinae-friendly result_of implementation. We use enable_if to transport
+ // both the result information (as the member type) and the failure
+ // information (no member type).
+
+ template<typename _Tp>
+ using __success_type = enable_if<true, _Tp>;
+
+ using __failure_type = enable_if<false>;
+
+ // [func.require] paragraph 1 bullet 1:
+ struct __result_of_memfun_ref_impl
+ {
+ template<typename _Fp, typename _Tp1, typename... _Args>
+ static __success_type<decltype(
+ (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun_ref
+ : private __result_of_memfun_ref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 2:
+ struct __result_of_memfun_deref_impl
+ {
+ template<typename _Fp, typename _Tp1, typename... _Args>
+ static __success_type<decltype(
+ ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun_deref
+ : private __result_of_memfun_deref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 3:
+ struct __result_of_memobj_ref_impl
+ {
+ template<typename _Fp, typename _Tp1>
+ static __success_type<decltype(
+ std::declval<_Tp1>().*std::declval<_Fp>()
+ )> _S_test(int);
+
+ template<typename, typename>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_memobj_ref
+ : private __result_of_memobj_ref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 4:
+ struct __result_of_memobj_deref_impl
+ {
+ template<typename _Fp, typename _Tp1>
+ static __success_type<decltype(
+ (*std::declval<_Tp1>()).*std::declval<_Fp>()
+ )> _S_test(int);
+
+ template<typename, typename>
+ static __failure_type _S_test(...);
+ };
+
template<typename _MemPtr, typename _Arg>
- struct _Result_of_memobj;
+ struct __result_of_memobj_deref
+ : private __result_of_memobj_deref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_memobj;
template<typename _Res, typename _Class, typename _Arg>
- struct _Result_of_memobj<_Res _Class::*, _Arg>
+ struct __result_of_memobj<_Res _Class::*, _Arg>
{
- private:
- typedef _Res _Class::* _Func;
-
- template<typename _Tp>
- static _Tp _S_get(const _Class&);
- template<typename _Tp>
- static _Tp _S_get(const volatile _Class&);
- template<typename _Tp>
- static decltype(*std::declval<_Tp>()) _S_get(...);
-
- public:
- typedef
- decltype(_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
- __type;
+ typedef typename remove_cv<typename remove_reference<
+ _Arg>::type>::type _Argval;
+ typedef _Res _Class::* _MemPtr;
+ typedef typename conditional<__or_<is_same<_Argval, _Class>,
+ is_base_of<_Class, _Argval>>::value,
+ __result_of_memobj_ref<_MemPtr, _Arg>,
+ __result_of_memobj_deref<_MemPtr, _Arg>
+ >::type::type type;
};
- template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
- struct _Result_of_memfun;
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun;
template<typename _Res, typename _Class, typename _Arg, typename... _Args>
- struct _Result_of_memfun<_Res _Class::*, _Arg, _Args...>
+ struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
{
- private:
- typedef _Res _Class::* _Func;
-
- template<typename _Tp>
- static _Tp _S_get(const _Class&);
- template<typename _Tp>
- static _Tp _S_get(const volatile _Class&);
- template<typename _Tp>
- static decltype(*std::declval<_Tp>()) _S_get(...);
-
- public:
- typedef
- decltype((_S_get<_Arg>(std::declval<_Arg>()).*std::declval<_Func>())
- (std::declval<_Args>()...) )
- __type;
+ typedef typename remove_cv<typename remove_reference<
+ _Arg>::type>::type _Argval;
+ typedef _Res _Class::* _MemPtr;
+ typedef typename conditional<__or_<is_same<_Argval, _Class>,
+ is_base_of<_Class, _Argval>>::value,
+ __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
+ __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
+ >::type::type type;
};
template<bool, bool, typename _Functor, typename... _ArgTypes>
- struct _Result_of_impl;
-
- template<typename _Functor, typename... _ArgTypes>
- struct _Result_of_impl<false, false, _Functor, _ArgTypes...>
+ struct __result_of_impl
{
- typedef
- decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) )
- __type;
+ typedef __failure_type type;
};
template<typename _MemPtr, typename _Arg>
- struct _Result_of_impl<true, false, _MemPtr, _Arg>
- : _Result_of_memobj<typename decay<_MemPtr>::type, _Arg>
+ struct __result_of_impl<true, false, _MemPtr, _Arg>
+ : public __result_of_memobj<typename decay<_MemPtr>::type, _Arg>
{ };
- template<typename _MemPtr, typename _Arg, typename... _ArgTypes>
- struct _Result_of_impl<false, true, _MemPtr, _Arg, _ArgTypes...>
- : _Result_of_memfun<typename decay<_MemPtr>::type, _Arg, _ArgTypes...>
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
+ : public __result_of_memfun<typename decay<_MemPtr>::type, _Arg, _Args...>
{ };
+ // [func.require] paragraph 1 bullet 5:
+ struct __result_of_other_impl
+ {
+ template<typename _Fn, typename... _Args>
+ static __success_type<decltype(
+ std::declval<_Fn>()(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
template<typename _Functor, typename... _ArgTypes>
- struct result_of<_Functor(_ArgTypes...)>
- : _Result_of_impl<is_member_object_pointer<
- typename remove_reference<_Functor>::type >::value,
- is_member_function_pointer<
- typename remove_reference<_Functor>::type >::value,
- _Functor, _ArgTypes...>
+ struct __result_of_impl<false, false, _Functor, _ArgTypes...>
+ : private __result_of_other_impl
{
- typedef typename _Result_of_impl<
- is_member_object_pointer<
- typename remove_reference<_Functor>::type >::value,
- is_member_function_pointer<
- typename remove_reference<_Functor>::type >::value,
- _Functor, _ArgTypes...>::__type
- type;
+ typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
};
+ template<typename _Functor, typename... _ArgTypes>
+ struct result_of<_Functor(_ArgTypes...)>
+ : public __result_of_impl<
+ is_member_object_pointer<
+ typename remove_reference<_Functor>::type
+ >::value,
+ is_member_function_pointer<
+ typename remove_reference<_Functor>::type
+ >::value,
+ _Functor, _ArgTypes...
+ >::type
+ { };
+
/**
* Use SFINAE to determine if the type _Tp has a publicly-accessible
* member type _NTYPE.
--- /dev/null
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <cstddef>
+#include <type_traits>
+
+// TODO: Uncomment the following define once gcc has fixed bug 52748
+// (incomplete types in function call expressions):
+//#define HAS_52748_FIXED
+
+// Helper types:
+struct has_type_impl
+{
+ template<class T, class = typename T::type>
+ static std::true_type test(int);
+
+ template<class>
+ static std::false_type test(...);
+};
+
+template<class T>
+struct has_type : decltype(has_type_impl::test<T>(0))
+{};
+
+template<class T, class Res>
+struct is_expected_type : std::is_same<typename T::type, Res>
+{};
+
+template<class T, class Res>
+struct is_type : std::__and_<has_type<T>, is_expected_type<T, Res>>
+{};
+
+// Types under inspection:
+
+typedef bool (&PF1)();
+typedef short (*PF2)(long);
+
+struct S {
+ operator PF2() const;
+ double operator()(char, int&);
+ void calc(long) const;
+};
+
+typedef void (S::*PMS)(long) const;
+typedef void (S::*PMSnonconst)(long);
+
+typedef int S::* PMI;
+
+struct B {
+ int i;
+ void f1() const;
+ bool f2(int) const volatile;
+};
+
+struct D : B {};
+
+typedef void (B::*base_func_void)() const;
+typedef bool (B::*base_func_bool_int)(int) const volatile;
+
+struct ident_functor {
+ template<class T>
+ T operator()(T&& x);
+};
+
+template<class Ret = void>
+struct variable_functor {
+ template<class... T>
+ Ret operator()(T&&...);
+};
+
+struct ident_functor_noref {
+ template<class T>
+ typename std::remove_reference<T>::type operator()(T&& x);
+};
+
+enum class ScEn;
+
+enum UnScEn : int;
+
+union U {
+ int i;
+ double d;
+};
+
+union U2 {
+ int i;
+ bool b;
+ void operator()() const;
+ int operator()(double) const;
+ bool operator()(double);
+ U operator()(int, int);
+};
+
+struct Ukn;
+
+typedef Ukn (S::*PMSIncomplete)(long) const;
+typedef Ukn (S::*PMSIncompletenonconst)(long);
+typedef Ukn (*FuncIncomplete)(long);
+
+struct Abstract {
+ virtual ~Abstract() = 0;
+};
+
+struct Private {
+private:
+ void operator()();
+ int operator()(int);
+public:
+ bool operator()(std::nullptr_t);
+};
+
+union PrivateUnion {
+ double d;
+private:
+ void operator()();
+ int operator()(int);
+public:
+ bool operator()(std::nullptr_t);
+};
+
+template<class T>
+struct ImplicitTo {
+ operator T();
+};
+
+template<class>
+struct never { static const bool value = false; };
+
+template<class T>
+struct BrokenTrait {
+ static_assert(never<T>::value, "Error!");
+ typedef T type;
+};
+
+template<class T>
+struct BadSmartPtr : T {
+ T& operator*() const noexcept(typename BrokenTrait<T>::type());
+};
+
+template<class Ret>
+using FuncEllipses = Ret(...);
+
+static_assert(is_type<std::result_of<S(int)>, short>::value, "Error!");
+static_assert(is_type<std::result_of<S&(unsigned char, int&)>,
+ double>::value, "Error!");
+static_assert(is_type<std::result_of<PF1()>, bool>::value, "Error!");
+static_assert(is_type<std::result_of<PF1&()>, bool>::value, "Error!");
+static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>&, unsigned&)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>, int)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>&, unsigned&)>,
+ void>::value, "Error!");
+
+static_assert(is_type<std::result_of<ident_functor(int)>,
+ int>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(const int)>,
+ int>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(const int&&)>,
+ int>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(int&&)>,
+ int>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(int&)>,
+ int&>::value, "Error!");
+
+static_assert(is_type<std::result_of<ident_functor(const B)>,
+ B>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(const B&&)>,
+ const B>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(B&&)>, B>::value, "Error!");
+static_assert(is_type<std::result_of<ident_functor(B&)>, B&>::value, "Error!");
+
+static_assert(is_type<std::result_of<int B::*(B&)>, int&>::value, "Error!");
+
+// This is expected as of CWG 616 P/R:
+static_assert(is_type<std::result_of<int B::*(B)>, int&&>::value, "Error!");
+
+static_assert(is_type<std::result_of<volatile int B::*(const B&&)>,
+ const volatile int&&>::value, "Error!");
+static_assert(is_type<std::result_of<const int B::*(volatile B&&)>,
+ const volatile int&&>::value, "Error!");
+
+static_assert(is_type<std::result_of<int B::*(const B&)>,
+ const int&>::value, "Error!");
+static_assert(is_type<std::result_of<volatile int B::*(const B&)>,
+ const volatile int&>::value, "Error!");
+static_assert(is_type<std::result_of<const int B::*(volatile B&)>,
+ const volatile int&>::value, "Error!");
+
+static_assert(is_type<std::result_of<int B::*(B*)>, int&>::value, "Error!");
+static_assert(is_type<std::result_of<int B::*(B*&)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<int B::*(const B*)>,
+ const int&>::value, "Error!");
+static_assert(is_type<std::result_of<int B::*(const B*&)>,
+ const int&>::value, "Error!");
+static_assert(is_type<std::result_of<volatile int B::*(const B*)>,
+ const volatile int&>::value, "Error!");
+static_assert(is_type<std::result_of<const int B::*(volatile B*)>,
+ const volatile int&>::value, "Error!");
+
+static_assert(is_type<std::result_of<base_func_void(const B&)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_void(const B*)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_void(B&)>,
+ void>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_void(B*)>,
+ void>::value, "Error!");
+
+static_assert(!has_type<std::result_of<base_func_void(volatile B&)>>::value,
+ "Error!");
+static_assert(!has_type<std::result_of<base_func_void(volatile B*)>>::value,
+ "Error!");
+
+static_assert(is_type<std::result_of<base_func_bool_int(B&, long)>,
+ bool>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_bool_int(B*, long)>,
+ bool>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_bool_int(volatile B&, long)>,
+ bool>::value, "Error!");
+static_assert(is_type<std::result_of<base_func_bool_int(volatile B*, long)>,
+ bool>::value, "Error!");
+
+static_assert(!has_type<std::result_of<int()>>(), "Error!");
+static_assert(!has_type<std::result_of<void()>>(), "Error!");
+static_assert(!has_type<std::result_of<int(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<void(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PF1(int)>>(), "Error!");
+static_assert(is_type<std::result_of<PF2(long)>, short>(), "Error!");
+static_assert(!has_type<std::result_of<PF2()>>(), "Error!");
+static_assert(!has_type<std::result_of<PF2(B)>>(), "Error!");
+static_assert(!has_type<std::result_of<PF2(ScEn)>>(), "Error!");
+static_assert(is_type<std::result_of<PF2(UnScEn)>, short>(), "Error!");
+static_assert(!has_type<std::result_of<PF2(long, int)>>(), "Error!");
+static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>, void>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMS(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(int, std::unique_ptr<S>)>>(), "Error!");
+
+// Argument number mismatch:
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, int, bool)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, int, bool)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMS(S)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(S&)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(S, int, bool)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(S&, int, bool)>>(), "Error!");
+
+// Non-convertible arguments:
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, S)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, S)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMS(S, S)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMS(S&, S)>>(), "Error!");
+
+// cv-violations:
+static_assert(!has_type<std::result_of<PMSnonconst(const S&, long)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMSnonconst(const S&&, long)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMSnonconst(const S*, long)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PMSnonconst(const S*&, long)>>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<PMI(S*)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<PMI(S&)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<PMI(S&&)>, int&&>(), "Error!");
+static_assert(is_type<std::result_of<PMI(S)>, int&&>(), "Error!");
+
+static_assert(!has_type<std::result_of<PMI()>>(), "Error!");
+
+static_assert(!has_type<std::result_of<PMI(S*, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMI(S&, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMI(S*, int, S, bool)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMI(S&, int, S, bool)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<PMI(B*)>>(), "Error!");
+static_assert(!has_type<std::result_of<PMI(B&)>>(), "Error!");
+
+static_assert(is_type<std::result_of<int U::*(U)>, int&&>(), "Error!");
+static_assert(is_type<std::result_of<int U::*(U&)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<int U::*(const U&)>, const int&>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <volatile int U::*(const U&)>, const volatile int&>(), "Error!");
+static_assert(is_type<std::result_of
+ <const int U::*(volatile U&)>, const volatile int&>(), "Error!");
+
+static_assert(is_type<std::result_of<int Ukn::*(Ukn*)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<int Ukn::*(Ukn&)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<int Ukn::*(Ukn&&)>, int&&>(), "Error!");
+static_assert(is_type<std::result_of<int Ukn::*(const Ukn*)>, const int&>(),
+ "Error!");
+static_assert(is_type<std::result_of<int Ukn::*(const Ukn&)>, const int&>(),
+ "Error!");
+static_assert(is_type<std::result_of<int Ukn::*(const Ukn&&)>, const int&&>(),
+ "Error!");
+
+typedef void (Ukn::* PUfnMF)();
+typedef void (Ukn::* PUfnConstMF)() const;
+
+static_assert(is_type<std::result_of<PUfnMF(Ukn*)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnMF(Ukn&)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnMF(Ukn&&)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(Ukn*)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(Ukn&)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(Ukn&&)>, void>(), "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(const Ukn*)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&&)>, void>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<S()>>(), "Error!");
+static_assert(!has_type<std::result_of<S(int, S)>>(), "Error!");
+static_assert(!has_type<std::result_of<S(S)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <S(double, bool, std::nullptr_t, Ukn&)>>(), "Error!");
+
+static_assert(is_type<std::result_of<U2()>, void>(), "Error!");
+static_assert(is_type<std::result_of<const U2&()>, void>(), "Error!");
+static_assert(is_type<std::result_of<U2&()>, void>(), "Error!");
+static_assert(is_type<std::result_of<U2(double)>, bool>(), "Error!");
+static_assert(is_type<std::result_of<const U2&(double)>, int>(), "Error!");
+static_assert(is_type<std::result_of<U2&(double)>, bool>(), "Error!");
+static_assert(is_type<std::result_of<U2(int)>, bool>(), "Error!");
+static_assert(is_type<std::result_of<U2&(int)>, bool>(), "Error!");
+static_assert(is_type<std::result_of<const U2&(int)>, int>(), "Error!");
+static_assert(is_type<std::result_of<U2(int, int)>, U>(), "Error!");
+static_assert(is_type<std::result_of<U2&(int, int)>, U>(), "Error!");
+
+static_assert(!has_type<std::result_of<const U2&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<U2(int, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<U2&(int, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const U2&(int, int, int)>>(), "Error!");
+
+static_assert(is_type<std::result_of<ident_functor(int)>, int>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(const volatile int)>,
+ int>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(int&)>, int&>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(const volatile int&)>,
+ const volatile int&>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(int&&)>, int>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(const volatile int&&)>,
+ int>(), "Error!");
+static_assert(is_type<std::result_of<ident_functor(Abstract&)>, Abstract&>(),
+ "Error!");
+static_assert(is_type<std::result_of<ident_functor(const volatile Abstract&)>,
+ const volatile Abstract&>(), "Error!");
+
+static_assert(!has_type<std::result_of<ident_functor(int(&&)[1])>>(), "Error!");
+static_assert(!has_type<std::result_of<ident_functor(Abstract&&)>>(), "Error!");
+static_assert(!has_type<std::result_of<ident_functor(const int(&&)[1])>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ident_functor(const Abstract&&)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ident_functor_noref(int(&)[1])>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ident_functor_noref
+ (const int(&)[1])>>(), "Error!");
+static_assert(!has_type<std::result_of<ident_functor_noref(Abstract&)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <ident_functor_noref(const Abstract&)>>(), "Error!");
+static_assert(!has_type<std::result_of<ident_functor_noref(void(&)())>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ident_functor_noref(void(&&)())>>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<ident_functor()>>(), "Error!");
+static_assert(!has_type<std::result_of<ident_functor(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const ident_functor&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const ident_functor&&(int)>>(),
+ "Error!");
+
+// Border-line case:
+static_assert(!has_type<std::result_of<int S::*(Ukn*)>>(), "Error!");
+static_assert(!has_type<std::result_of<void (S::*(Ukn*))()>>(), "Error!");
+
+// We want to allow this, it seems to be required by the order described
+// in [func.require] p1:
+static_assert(is_type<std::result_of<int S::*(BadSmartPtr<S>&)>, int&>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<Private(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<Private&(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<Private&&(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<Private(ImplicitTo<std::nullptr_t>)>,
+ bool>(), "Error!");
+static_assert(is_type<std::result_of<Private&(ImplicitTo<std::nullptr_t>)>,
+ bool>(), "Error!");
+static_assert(is_type<std::result_of<Private&&(ImplicitTo<std::nullptr_t>)>,
+ bool>(), "Error!");
+
+static_assert(!has_type<std::result_of<const Private&(std::nullptr_t)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const Private&&(std::nullptr_t)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<Private()>>(), "Error!");
+static_assert(!has_type<std::result_of<Private(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&()>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&()>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&&()>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private&&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&&()>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&&(int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<Private(ScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private(UnScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&(ScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<const Private&(UnScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private(ImplicitTo<ScEn>)>>(), "Error!");
+static_assert(!has_type<std::result_of<Private(ImplicitTo<UnScEn>)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const Private&(ImplicitTo<ScEn>)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const Private&(ImplicitTo<UnScEn>)>>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<PrivateUnion(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<PrivateUnion&(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<PrivateUnion&&(std::nullptr_t)>, bool>(),
+ "Error!");
+static_assert(is_type<std::result_of<PrivateUnion(ImplicitTo<std::nullptr_t>)>,
+ bool>(), "Error!");
+static_assert(is_type<std::result_of
+ <PrivateUnion&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
+static_assert(is_type<std::result_of
+ <PrivateUnion&&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!");
+
+static_assert(!has_type<std::result_of<const PrivateUnion&(std::nullptr_t)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const PrivateUnion&&(std::nullptr_t)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion()>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&()>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&()>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&(int, int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&&()>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion&&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&&()>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&&(int)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&&(int, int)>>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<PrivateUnion(ScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion(UnScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&(ScEn)>>(), "Error!");
+static_assert(!has_type<std::result_of<const PrivateUnion&(UnScEn)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<ScEn>)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<UnScEn>)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const PrivateUnion&(ImplicitTo<ScEn>)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const PrivateUnion&(ImplicitTo<UnScEn>)>>(), "Error!");
+
+static_assert(is_type<std::result_of<void(*(bool))(int)>, void>(), "Error!");
+static_assert(is_type<std::result_of<void(*(UnScEn))(int)>, void>(), "Error!");
+static_assert(is_type<std::result_of<void(*(ImplicitTo<int>))(int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&))(int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&&))(int)>, void>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<void(*(ScEn))(int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <void(*(const ImplicitTo<int>&))(int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <void(*(const ImplicitTo<int>&&))(int)>>(), "Error!");
+
+static_assert(is_type<std::result_of<ImplicitTo<void(*)()>()>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<ImplicitTo<void(&)()>()>, void>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<ImplicitTo<void(*)()>(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ImplicitTo<void(*)(int)>()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ImplicitTo<void(&)()>(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<ImplicitTo<void(&)(int)>()>>(),
+ "Error!");
+
+// Conversion operators of types are not considered in call expressions
+// (except for conversion to function pointer/reference):
+static_assert(!has_type<std::result_of<ImplicitTo<S>(char, int&)>>(), "Error!");
+static_assert(!has_type<std::result_of<ImplicitTo<ident_functor>(int)>>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<variable_functor<>()>, void>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<>(int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<>(int, int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<>(int, int, int)>,
+ void>(), "Error!");
+
+static_assert(is_type<std::result_of<variable_functor<>&()>, void>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<>&(int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<>&(int, int)>, void>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<>&(int, int, int)>,
+ void>(), "Error!");
+
+static_assert(!has_type<std::result_of<const variable_functor<>()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<>(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<>(int, int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<>(int, int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<const variable_functor<>&()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<>&(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<>&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<>&(int, int, int)>>(), "Error!");
+
+static_assert(is_type<std::result_of<variable_functor<S>()>, S>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<S>(int)>, S>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<S>(int, int)>, S>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<S>(int, int, int)>, S>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<variable_functor<S>&()>, S>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<S>&(int)>, S>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<S>&(int, int)>, S>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <variable_functor<S>&(int, int, int)>, S>(), "Error!");
+
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>()>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>(int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>(int, int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<const variable_functor<S>&()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<S>&(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<S>&(int, int, int)>>(), "Error!");
+
+#if defined(HAS_52748_FIXED)
+static_assert(has_type<std::result_of<variable_functor<Ukn>()>>(), "Error!");
+static_assert(is_type<std::result_of<variable_functor<Ukn>()>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<Ukn>(int)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<Ukn>(int, int)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <variable_functor<Ukn>(int, int, int)>, Ukn>(), "Error!");
+
+static_assert(is_type<std::result_of<variable_functor<Ukn>&()>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<variable_functor<Ukn>&(int)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <variable_functor<Ukn>&(int, int)>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of
+ <variable_functor<Ukn>&(int, int, int)>, Ukn>(), "Error!");
+
+static_assert(is_type<std::result_of<PMSIncomplete(int)>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<PMSIncomplete&(int)>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<PMSIncomplete&&(int)>, Ukn>(), "Error!");
+
+static_assert(is_type<std::result_of<FuncIncomplete(int)>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<FuncIncomplete&(int)>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<FuncIncomplete&&(int)>, Ukn>(), "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>*()>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>&()>, Ukn>(), "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&()>, Ukn>(), "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&(bool)>, Ukn>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool, int, S)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool, int, S)>, Ukn>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <FuncEllipses<Ukn>&&(bool, int, S)>, Ukn>(), "Error!");
+
+static_assert(!has_type<std::result_of<PMSIncompletenonconst(const S*)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*, int, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*&)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*&, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*&, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S*&, int, int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&, int, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&&)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&&, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&&, int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <PMSIncompletenonconst(const S&&, int, int, int)>>(), "Error!");
+#endif
+
+static_assert(!has_type<std::result_of<const variable_functor<Ukn>()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<Ukn>(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<Ukn>(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<Ukn>(int, int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<const variable_functor<Ukn>&()>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<const variable_functor<Ukn>&(int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<Ukn>&(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of
+ <const variable_functor<Ukn>&(int, int, int)>>(), "Error!");
+
+static_assert(!has_type<std::result_of<FuncIncomplete()>>(), "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete(S)>>(), "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete(int, int)>>(), "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete(int, int, int)>>(),
+ "Error!");
+
+static_assert(!has_type<std::result_of<FuncIncomplete&&()>>(), "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete&&(S)>>(), "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int)>>(),
+ "Error!");
+static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int, int)>>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<int>*()>, int>(), "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<int>&()>, int>(), "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<int>&&()>, int>(), "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<int>*(bool)>, int>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<int>&(bool)>, int>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<int>&&(bool)>, int>(),
+ "Error!");
+
+static_assert(is_type<std::result_of<FuncEllipses<int>*(bool, int, S)>, int>(),
+ "Error!");
+static_assert(is_type<std::result_of<FuncEllipses<int>&(bool, int, S)>, int>(),
+ "Error!");
+static_assert(is_type<std::result_of
+ <FuncEllipses<int>&&(bool, int, S)>, int>(), "Error!");
+