From f1626ad28d17b066f991c354e089f52a0268adbc Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 26 Aug 2015 20:15:02 +0000 Subject: [PATCH] [libcxx] Rewrite C++03 __invoke. Summary: This patch rewrites the C++03 `__invoke` and related meta-programming. There are a number of major changes. `__invoke` in C++03 now has a fallback overload for when the invoke expression is ill-formed (similar to C++11). This means that the `__invoke_return` traits will return `__nat` when `__invoke(...)` is ill formed. This would previously cause a compile error. Bullets 1-4 of `__invoke` have been rewritten. In the old version `__invoke` had 32 overloads for bullets 1 and 2, one for each possible cv-qualified function signature with arities 0-3. 64 overloads would be needed to support member functions with varargs. Currently these overloads were fundamentally broken. An example overload looked like: ``` template Rp __invoke(Rp (Tp::*pm)(A0) const, T1&, A0&) ``` Because `A0` appeared in two different deducible contexts it would have to deduce to be an exact match or the overload would be rejected. This is made even worse because `A0` appears without a reference qualifier in the member function signature and with a reference qualifier as an `__invoke` parameter. This means that only member functions that took all of their arguments by value could be matched. One possible fix would be to make the second occurrence of `A0` appear in a non-deducible context. This way any type convertible to `A0` could be passed as the first parameter. The benefit of this approach is that the signature of the member function enforces the arity and types taken by the `__invoke` signature it generates. However nothing in the `INVOKE` specification requires this behavior. My solution is to use a `__invoke_enable_if` metafunction to selectively enable the `__invoke` overloads for bullets 1, 2, 3 and 4. It uses `__member_function_traits` to inspect and extract the return type and class type of the pointer to member. Using `__member_function_traits` to inspect `PM_Type` also allows us to reduce the number of `__invoke` overloads from 32 to 8 and add varargs support at the same time. Because `__invoke_enable_if` knows the exact return type of `__invoke` for bullets 1-4 we no longer need to use `decltype(__invoke(...))` to compute the return type in the `__invoke_return*` traits. This will reduce the problems caused by `#define decltype(X) __typeof__(X)` in C++03. Tests for this change have already been committed. All tests in `test/std/utilities/function.objects` now pass in C++03, previously there were 20 failures. Reviewers: K-ballo, howard.hinnant, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11553 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246068 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__functional_base | 128 ++++- include/__functional_base_03 | 492 ++++-------------- include/functional | 80 +++ .../refwrap/refwrap.const/type_ctor.fail.cpp | 2 + .../refwrap/refwrap.helpers/ref_1.fail.cpp | 2 + 5 files changed, 280 insertions(+), 424 deletions(-) diff --git a/include/__functional_base b/include/__functional_base index 3ff2e350..ef9cc032 100644 --- a/include/__functional_base +++ b/include/__functional_base @@ -515,44 +515,116 @@ public: #ifndef _LIBCPP_HAS_NO_VARIADICS // invoke template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const - { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_of::type + operator() (_ArgTypes&&... __args) const { + return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); + } #else _LIBCPP_INLINE_VISIBILITY typename __invoke_return::type - operator() () const - { - return __invoke(get()); - } + operator() () const { + return __invoke(get()); + } template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0& __a0) const - { - return __invoke(get(), __a0); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return __invoke(get(), __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return __invoke(get(), __a0); + } template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const - { - return __invoke(get(), __a0, __a1); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return __invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return __invoke(get(), __a0, __a1); + } template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const - { - return __invoke(get(), __a0, __a1, __a2); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(get(), __a0, __a1, __a2); + } #endif // _LIBCPP_HAS_NO_VARIADICS }; diff --git a/include/__functional_base_03 b/include/__functional_base_03 index 0a7ff62e..8407dcfa 100644 --- a/include/__functional_base_03 +++ b/include/__functional_base_03 @@ -14,431 +14,128 @@ // manual variadic expansion for // __invoke + +template +struct __enable_invoke_imp; + +template +struct __enable_invoke_imp<_Ret, _T1, true, true> { + typedef _Ret _Bullet1; + typedef _Bullet1 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, true, false> { + typedef _Ret _Bullet2; + typedef _Bullet2 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, true> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet3; + typedef _Bullet3 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv()), _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1*, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template , + class _Ret = typename _Traits::_ReturnType, + class _Class = typename _Traits::_ClassType> +struct __enable_invoke : __enable_invoke_imp< + _Ret, _T1, + is_member_function_pointer<_Fn>::value, + is_base_of<_Class, typename remove_reference<_T1>::type>::value> +{ +}; + +__nat __invoke(__any, ...); + // first bullet -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1) { return (__t1.*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1& __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return (__t1.*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1& __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return (__t1.*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return (__t1.*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -// second bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1 __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1) { return ((*__t1).*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1 __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return ((*__t1).*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1 __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return ((*__t1).*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return ((*__t1).*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -// third bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_member_object_pointer<_Rp _Tp::*>::value && - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - __apply_cv<_T1, _Rp> ->::type::type& -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet3 +__invoke(_Fn __f, _T1& __t1) { return __t1.*__f; } - -// forth bullet - -template -struct __4th_helper -{ -}; - -template -struct __4th_helper<_T1, _Rp, true> -{ - typedef typename __apply_cv()), _Rp>::type type; -}; - -template +template inline _LIBCPP_INLINE_VISIBILITY -typename __4th_helper<_T1, _Rp, - is_member_object_pointer<_Rp _Tp::*>::value && - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value ->::type& -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet4 +__invoke(_Fn __f, _T1& __t1) { return (*__t1).*__f; } @@ -488,29 +185,28 @@ struct __invoke_return<_Fp, false> typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type; }; -template ::value> +template struct __invoke_return0 { typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type; }; template -struct __invoke_return0<_Rp _Tp::*, _A0, true> +struct __invoke_return0<_Rp _Tp::*, _A0> { - typedef typename __apply_cv<_A0, _Rp>::type& type; -}; - -template -struct __invoke_return0<_Rp _Tp::*, _A0*, true> -{ - typedef typename __apply_cv<_A0, _Rp>::type& type; + typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; }; template struct __invoke_return1 { typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), - _VSTD::declval<_A1&>())) type; + _VSTD::declval<_A1&>())) type; +}; + +template +struct __invoke_return1<_Rp _Class::*, _A0, _A1> { + typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; }; template @@ -521,4 +217,8 @@ struct __invoke_return2 _VSTD::declval<_A2&>())) type; }; +template +struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { + typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; +}; #endif // _LIBCPP_FUNCTIONAL_BASE_03 diff --git a/include/functional b/include/functional index 3c9f5a75..13286482 100644 --- a/include/functional +++ b/include/functional @@ -1262,22 +1262,102 @@ public: #else template + _LIBCPP_INLINE_VISIBILITY typename __invoke_return0::type operator() (_A0& __a0) const { return __invoke(__f_, __a0); } + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return __invoke(__f_, __a0); + } + template + _LIBCPP_INLINE_VISIBILITY typename __invoke_return1::type operator() (_A0& __a0, _A1& __a1) const { return __invoke(__f_, __a0, __a1); } + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + template + _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } #endif }; diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp index ba46946a..a2316063 100644 --- a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp +++ b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp @@ -13,6 +13,8 @@ // reference_wrapper(T&&) = delete; +// XFAIL: c++98, c++03 + #include #include diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp index 86a5696f..0aad4986 100644 --- a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp +++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp @@ -15,6 +15,8 @@ // Don't allow binding to a temp +// XFAIL: c++98, c++03 + #include struct A {};