[libcxx] r266590 - Implement LWG issue 2219 - support reference_wrapper in INVOKE

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 17 23:17:31 PDT 2016


Author: ericwf
Date: Mon Apr 18 01:17:30 2016
New Revision: 266590

URL: http://llvm.org/viewvc/llvm-project?rev=266590&view=rev
Log:
Implement LWG issue 2219 - support reference_wrapper in INVOKE

Added:
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp
Removed:
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp
Modified:
    libcxx/trunk/include/__functional_base
    libcxx/trunk/include/type_traits
    libcxx/trunk/include/utility
    libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h
    libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
    libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__functional_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Mon Apr 18 01:17:30 2016
@@ -322,6 +322,17 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&&
     return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
 }
 
+
+template <class _Fp, class _A0, class ..._Args,
+            class>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+    -> decltype((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
+{
+    return (__a0.get().*__f)(_VSTD::forward<_Args>(__args)...);
+}
+
 template <class _Fp, class _A0, class ..._Args,
             class>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -344,6 +355,17 @@ __invoke(_Fp&& __f, _A0&& __a0)
     return _VSTD::forward<_A0>(__a0).*__f;
 }
 
+
+template <class _Fp, class _A0,
+            class>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+    -> decltype(__a0.get().*__f)
+{
+    return __a0.get().*__f;
+}
+
 template <class _Fp, class _A0,
             class>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -577,10 +599,6 @@ public:
 #endif // _LIBCPP_HAS_NO_VARIADICS
 };
 
-template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
-template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
-template <class _Tp> struct __is_reference_wrapper
-    : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
 
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Apr 18 01:17:30 2016
@@ -369,6 +369,7 @@ namespace std
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
 
 template <class>
 struct __void_t { typedef void type; };
@@ -3965,6 +3966,11 @@ template <class _Tp> _LIBCPP_CONSTEXPR b
     = is_trivial<_Tp>::value;
 #endif
 
+template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
+template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
+template <class _Tp> struct __is_reference_wrapper
+    : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
+
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 // Check for complete types
@@ -4111,6 +4117,15 @@ struct __check_complete<_Rp _Class::*>
 {
 };
 
+
+template <class _Fp, class _A0>
+using __arg_is_base_of_ptm =
+    is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
+               typename remove_reference<_A0>::type>;
+
+template <class _A0>
+using __arg_is_reference_wrapper = __is_reference_wrapper<typename decay<_A0>::type>;
+
 // __invoke forward declarations
 
 // fall back - none of the bullets
@@ -4120,14 +4135,13 @@ auto
 __invoke(__any, _Args&& ...__args)
     -> __nat;
 
-// bullets 1 and 2
+// bullets 1, 2 and 3
 
 template <class _Fp, class _A0, class ..._Args,
             class = typename enable_if
             <
                 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
-                is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
-                           typename remove_reference<_A0>::type>::value
+                __arg_is_base_of_ptm<_Fp, _A0>::value
             >::type
          >
 _LIBCPP_INLINE_VISIBILITY
@@ -4135,12 +4149,25 @@ auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
     -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
 
+
 template <class _Fp, class _A0, class ..._Args,
             class = typename enable_if
             <
                 is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
-                !is_base_of<typename remove_reference<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType>::type,
-                           typename remove_reference<_A0>::type>::value
+                __arg_is_reference_wrapper<_A0>::value
+            >::type
+         >
+_LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+    -> decltype((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...));
+
+template <class _Fp, class _A0, class ..._Args,
+            class = typename enable_if
+            <
+                is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
+                !__arg_is_base_of_ptm<_Fp, _A0>::value &&
+                !__arg_is_reference_wrapper<_A0>::value
             >::type
          >
 _LIBCPP_INLINE_VISIBILITY
@@ -4148,14 +4175,13 @@ auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
     -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
 
-// bullets 3 and 4
+// bullets 4, 5 and 6
 
 template <class _Fp, class _A0,
             class = typename enable_if
             <
                 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
-                is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
-                           typename remove_reference<_A0>::type>::value
+                __arg_is_base_of_ptm<_Fp, _A0>::value
             >::type
          >
 _LIBCPP_INLINE_VISIBILITY
@@ -4163,12 +4189,25 @@ auto
 __invoke(_Fp&& __f, _A0&& __a0)
     -> decltype(_VSTD::forward<_A0>(__a0).*__f);
 
+
+template <class _Fp, class _A0,
+            class = typename enable_if
+            <
+                is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
+                __arg_is_reference_wrapper<_A0>::value
+            >::type
+         >
+_LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+    -> decltype(__a0.get().*__f);
+
 template <class _Fp, class _A0,
             class = typename enable_if
             <
                 is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
-                !is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
-                           typename remove_reference<_A0>::type>::value
+                !__arg_is_base_of_ptm<_Fp, _A0>::value &&
+                !__arg_is_reference_wrapper<_A0>::value
             >::type
          >
 _LIBCPP_INLINE_VISIBILITY
@@ -4176,7 +4215,7 @@ auto
 __invoke(_Fp&& __f, _A0&& __a0)
     -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
 
-// bullet 5
+// bullet 7
 
 template <class _Fp, class ..._Args>
 _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Mon Apr 18 01:17:30 2016
@@ -501,7 +501,6 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
-template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
 
 template <class _Tp>
 struct __make_pair_return_impl

Modified: libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp Mon Apr 18 01:17:30 2016
@@ -174,6 +174,32 @@ void bullet_one_two_tests() {
     }
     {
         TestClass cl_obj(42);
+        std::reference_wrapper<TestClass> cl(cl_obj);
+        test_b12<int&(NonCopyable&&) &, int&>(cl);
+        test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+        test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+        test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+
+        test_b12<int&(NonCopyable&&) &, int&>(std::move(cl));
+        test_b12<int const&(NonCopyable&&) const &, int const&>(std::move(cl));
+        test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(std::move(cl));
+        test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(std::move(cl));
+    }
+    {
+        DerivedFromTestClass cl_obj(42);
+        std::reference_wrapper<DerivedFromTestClass> cl(cl_obj);
+        test_b12<int&(NonCopyable&&) &, int&>(cl);
+        test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
+        test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(cl);
+        test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(cl);
+
+        test_b12<int&(NonCopyable&&) &, int&>(std::move(cl));
+        test_b12<int const&(NonCopyable&&) const &, int const&>(std::move(cl));
+        test_b12<int volatile&(NonCopyable&&) volatile &, int volatile&>(std::move(cl));
+        test_b12<int const volatile&(NonCopyable&&) const volatile &, int const volatile&>(std::move(cl));
+    }
+    {
+        TestClass cl_obj(42);
         TestClass *cl = &cl_obj;
         test_b12<int&(NonCopyable&&) &, int&>(cl);
         test_b12<int const&(NonCopyable&&) const &, int const&>(cl);
@@ -219,6 +245,22 @@ void bullet_three_four_tests() {
     }
     {
         typedef TestClass Fn;
+        Fn cl(42);
+        test_b34<int&>(std::reference_wrapper<Fn>(cl));
+        test_b34<int const&>(std::reference_wrapper<Fn const>(cl));
+        test_b34<int volatile&>(std::reference_wrapper<Fn volatile>(cl));
+        test_b34<int const volatile&>(std::reference_wrapper<Fn const volatile>(cl));
+    }
+    {
+        typedef DerivedFromTestClass Fn;
+        Fn cl(42);
+        test_b34<int&>(std::reference_wrapper<Fn>(cl));
+        test_b34<int const&>(std::reference_wrapper<Fn const>(cl));
+        test_b34<int volatile&>(std::reference_wrapper<Fn volatile>(cl));
+        test_b34<int const volatile&>(std::reference_wrapper<Fn const volatile>(cl));
+    }
+    {
+        typedef TestClass Fn;
         Fn cl_obj(42);
         Fn* cl = &cl_obj;
         test_b34<int&>(cl);

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp?rev=266590&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp Mon Apr 18 01:17:30 2016
@@ -0,0 +1,367 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+//   - Bullet 1 -- (t1.*f)(t2, ..., tN)
+//   - Bullet 2 -- (t1.get().*f)(t2, ..., tN) // t1 is a reference_wrapper
+//   - Bullet 3 -- ((*t1).*f)(t2, ..., tN)
+//
+// Overview:
+//    Bullets 1, 2 and 3 handle the case where 'f' is a pointer to member function.
+//    Bullet 1 only handles the cases where t1 is an object of type T or a
+//    type derived from 'T'. Bullet 2 handles the case where 't1' is a reference
+//    wrapper and bullet 3 handles all other cases.
+//
+// Concerns:
+//   1) cv-qualified member function signatures are accepted.
+//   2) reference qualified member function signatures are accepted.
+//   3) member functions with varargs at the end are accepted.
+//   4) The arguments are perfect forwarded to the member function call.
+//   5) Classes that are publicly derived from 'T' are accepted as the call object
+//   6) All types that dereference to T or a type derived from T can be used
+//      as the call object.
+//   7) Pointers to T or a type derived from T can be used as the call object.
+//   8) Reference return types are properly deduced.
+//   9) reference_wrappers are properly handled and unwrapped.
+//
+//
+// Plan:
+//   1) Create a class that contains a set, 'S', of non-static functions.
+//     'S' should include functions that cover every single combination
+//      of qualifiers and varargs for arities of 0, 1 and 2 (C-1,2,3).
+//      The argument types used in the functions should be non-copyable (C-4).
+//      The functions should return 'MethodID::setUncheckedCall()'.
+//
+//   2) Create a set of supported call object, 'Objs', of different types
+//      and behaviors. (C-5,6,7)
+//
+//   3) Attempt to call each function, 'f', in 'S' with each call object, 'c',
+//      in 'Objs'. After every attempted call to 'f' check that 'f' was
+//      actually called using 'MethodID::checkCalled(<return-value>)'
+//
+//       3b) If 'f' is reference qualified call 'f' with the properly qualified
+//       call object. Otherwise call 'f' with lvalue call objects.
+//
+//       3a) If 'f' is const, volatile, or cv qualified then call it with call
+//       objects that are equally or less cv-qualified.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+//==============================================================================
+// MemFun03 - C++03 compatible set of test member functions.
+struct MemFun03 {
+    typedef void*& R;
+#define F(...) \
+    R f(__VA_ARGS__) { return MethodID<R(MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const { return MethodID<R(MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
+#
+    F()
+    F(...)
+    F(ArgType&)
+    F(ArgType&, ...)
+    F(ArgType&, ArgType&)
+    F(ArgType&, ArgType&, ...)
+    F(ArgType&, ArgType&, ArgType&)
+    F(ArgType&, ArgType&, ArgType&, ...)
+#undef F
+public:
+    MemFun03() {}
+private:
+    MemFun03(MemFun03 const&);
+    MemFun03& operator=(MemFun03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// MemFun11 - C++11 reference qualified test member functions.
+struct MemFun11 {
+    typedef void*& R;
+    typedef MemFun11 C;
+#define F(...) \
+    R f(__VA_ARGS__) & { return MethodID<R(C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const & { return MethodID<R(C::*)(__VA_ARGS__) const &>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) volatile & { return MethodID<R(C::*)(__VA_ARGS__) volatile &>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const volatile & { return MethodID<R(C::*)(__VA_ARGS__) const volatile &>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) && { return MethodID<R(C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const && { return MethodID<R(C::*)(__VA_ARGS__) const &&>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) volatile && { return MethodID<R(C::*)(__VA_ARGS__) volatile &&>::setUncheckedCall(); } \
+    R f(__VA_ARGS__) const volatile && { return MethodID<R(C::*)(__VA_ARGS__) const volatile &&>::setUncheckedCall(); }
+#
+    F()
+    F(...)
+    F(ArgType&&)
+    F(ArgType&&, ...)
+    F(ArgType&&, ArgType&&)
+    F(ArgType&&, ArgType&&, ...)
+    F(ArgType&&, ArgType&&, ArgType&&)
+    F(ArgType&&, ArgType&&, ArgType&&, ...)
+#undef F
+public:
+    MemFun11() {}
+private:
+    MemFun11(MemFun11 const&);
+    MemFun11& operator=(MemFun11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+
+//==============================================================================
+// TestCase - A test case for a single member function.
+//   ClassType - The type of the class being tested.
+//   CallSig   - The function signature of the method being tested.
+//   Arity     - the arity of 'CallSig'
+//   CV        - the cv qualifiers of 'CallSig' represented as a type tag.
+//   RValue    - The method is RValue qualified.
+//   ArgRValue - Call the method with RValue arguments.
+template <class ClassType, class CallSig, int Arity, class CV,
+          bool RValue = false, bool ArgRValue = false>
+struct TestCaseImp {
+public:
+
+    static void run() { TestCaseImp().doTest(); }
+
+private:
+    //==========================================================================
+    // TEST DISPATCH
+    void doTest() {
+         // (Plan-2) Create test call objects.
+        typedef ClassType T;
+        typedef DerivedFromType<T> D;
+        T obj;
+        T* obj_ptr = &obj;
+        D der;
+        D* der_ptr = &der;
+        DerefToType<T>   dref;
+        DerefPropType<T> dref2;
+        std::reference_wrapper<T> rref(obj);
+        std::reference_wrapper<D> drref(der);
+
+         // (Plan-3) Dispatch based on the CV tags.
+        CV tag;
+        Bool<!RValue> NotRValue;
+        runTestDispatch(tag,  obj);
+        runTestDispatch(tag,  der);
+        runTestDispatch(tag, dref2);
+        runTestDispatchIf(NotRValue, tag, dref);
+        runTestDispatchIf(NotRValue, tag, obj_ptr);
+        runTestDispatchIf(NotRValue, tag, der_ptr);
+#if TEST_STD_VER >= 11
+        runTestDispatchIf(NotRValue, tag, rref);
+        runTestDispatchIf(NotRValue, tag, drref);
+#endif
+    }
+
+    template <class QT, class Tp>
+    void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
+        runTestDispatch(q, v);
+    }
+
+    template <class QT, class Tp>
+    void runTestDispatchIf(Bool<false>, QT, Tp&) {
+    }
+
+    template <class Tp>
+    void runTestDispatch(Q_None, Tp& v) {
+        runTest(v);
+    }
+
+    template <class Tp>
+    void runTestDispatch(Q_Const, Tp& v) {
+        runTest(v);
+        runTest(makeConst(v));
+    }
+
+    template <class Tp>
+    void runTestDispatch(Q_Volatile, Tp& v) {
+        runTest(v);
+        runTest(makeVolatile(v));
+
+    }
+
+    template <class Tp>
+    void runTestDispatch(Q_CV, Tp& v) {
+        runTest(v);
+        runTest(makeConst(v));
+        runTest(makeVolatile(v));
+        runTest(makeCV(v));
+    }
+
+    template <class T>
+    void runTest(const std::reference_wrapper<T>& obj) {
+        typedef Caster<Q_None, RValue> SCast;
+        typedef Caster<Q_None, ArgRValue> ACast;
+        typedef CallSig (ClassType::*MemPtr);
+        // Delegate test to logic in invoke_helpers.h
+        BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+        b.runTest( (MemPtr)&ClassType::f, obj);
+    }
+
+    template <class T>
+    void runTest(T* obj) {
+        typedef Caster<Q_None, RValue> SCast;
+        typedef Caster<Q_None, ArgRValue> ACast;
+        typedef CallSig (ClassType::*MemPtr);
+        // Delegate test to logic in invoke_helpers.h
+        BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+        b.runTest( (MemPtr)&ClassType::f, obj);
+    }
+
+    template <class Obj>
+    void runTest(Obj& obj) {
+        typedef Caster<Q_None, RValue> SCast;
+        typedef Caster<Q_None, ArgRValue> ACast;
+        typedef CallSig (ClassType::*MemPtr);
+        // Delegate test to logic in invoke_helpers.h
+        BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+        b.runTest( (MemPtr)&ClassType::f, obj);
+    }
+};
+
+template <class Sig, int Arity, class CV>
+struct TestCase : public TestCaseImp<MemFun03, Sig, Arity, CV> {};
+
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class CV, bool RValue = false>
+struct TestCase11 : public TestCaseImp<MemFun11, Sig, Arity, CV, RValue, true> {};
+#endif
+
+template <class Tp>
+struct DerivedFromRefWrap : public std::reference_wrapper<Tp> {
+  DerivedFromRefWrap(Tp& tp) : std::reference_wrapper<Tp>(tp) {}
+};
+
+#if TEST_STD_VER >= 11
+void test_derived_from_ref_wrap() {
+    int x = 42;
+    std::reference_wrapper<int> r(x);
+    std::reference_wrapper<std::reference_wrapper<int>> r2(r);
+    DerivedFromRefWrap<int> d(x);
+    auto get_fn = &std::reference_wrapper<int>::get;
+    auto& ret = std::__invoke(get_fn, r);
+    assert(&ret == &x);
+    auto& ret2 = std::__invoke(get_fn, d);
+    assert(&ret2 == &x);
+    auto& ret3 = std::__invoke(get_fn, r2);
+    assert(&ret3 == &x);
+}
+#endif
+
+int main() {
+    typedef void*& R;
+    typedef ArgType A;
+    TestCase<R(),                                   0, Q_None>::run();
+    TestCase<R() const,                             0, Q_Const>::run();
+    TestCase<R() volatile,                          0, Q_Volatile>::run();
+    TestCase<R() const volatile,                    0, Q_CV>::run();
+    TestCase<R(...),                                0, Q_None>::run();
+    TestCase<R(...) const,                          0, Q_Const>::run();
+    TestCase<R(...) volatile,                       0, Q_Volatile>::run();
+    TestCase<R(...) const volatile,                 0, Q_CV>::run();
+    TestCase<R(A&),                                 1, Q_None>::run();
+    TestCase<R(A&) const,                           1, Q_Const>::run();
+    TestCase<R(A&) volatile,                        1, Q_Volatile>::run();
+    TestCase<R(A&) const volatile,                  1, Q_CV>::run();
+    TestCase<R(A&, ...),                            1, Q_None>::run();
+    TestCase<R(A&, ...) const,                      1, Q_Const>::run();
+    TestCase<R(A&, ...) volatile,                   1, Q_Volatile>::run();
+    TestCase<R(A&, ...) const volatile,             1, Q_CV>::run();
+    TestCase<R(A&, A&),                             2, Q_None>::run();
+    TestCase<R(A&, A&) const,                       2, Q_Const>::run();
+    TestCase<R(A&, A&) volatile,                    2, Q_Volatile>::run();
+    TestCase<R(A&, A&) const volatile,              2, Q_CV>::run();
+    TestCase<R(A&, A&, ...),                        2, Q_None>::run();
+    TestCase<R(A&, A&, ...) const,                  2, Q_Const>::run();
+    TestCase<R(A&, A&, ...) volatile,               2, Q_Volatile>::run();
+    TestCase<R(A&, A&, ...) const volatile,         2, Q_CV>::run();
+    TestCase<R(A&, A&, A&),                         3, Q_None>::run();
+    TestCase<R(A&, A&, A&) const,                   3, Q_Const>::run();
+    TestCase<R(A&, A&, A&) volatile,                3, Q_Volatile>::run();
+    TestCase<R(A&, A&, A&) const volatile,          3, Q_CV>::run();
+    TestCase<R(A&, A&, A&, ...),                    3, Q_None>::run();
+    TestCase<R(A&, A&, A&, ...) const,              3, Q_Const>::run();
+    TestCase<R(A&, A&, A&, ...) volatile,           3, Q_Volatile>::run();
+    TestCase<R(A&, A&, A&, ...) const volatile,     3, Q_CV>::run();
+
+#if TEST_STD_VER >= 11
+    TestCase11<R() &,                               0, Q_None>::run();
+    TestCase11<R() const &,                         0, Q_Const>::run();
+    TestCase11<R() volatile &,                      0, Q_Volatile>::run();
+    TestCase11<R() const volatile &,                0, Q_CV>::run();
+    TestCase11<R(...) &,                            0, Q_None>::run();
+    TestCase11<R(...) const &,                      0, Q_Const>::run();
+    TestCase11<R(...) volatile &,                   0, Q_Volatile>::run();
+    TestCase11<R(...) const volatile &,             0, Q_CV>::run();
+    TestCase11<R(A&&) &,                            1, Q_None>::run();
+    TestCase11<R(A&&) const &,                      1, Q_Const>::run();
+    TestCase11<R(A&&) volatile &,                   1, Q_Volatile>::run();
+    TestCase11<R(A&&) const volatile &,             1, Q_CV>::run();
+    TestCase11<R(A&&, ...) &,                       1, Q_None>::run();
+    TestCase11<R(A&&, ...) const &,                 1, Q_Const>::run();
+    TestCase11<R(A&&, ...) volatile &,              1, Q_Volatile>::run();
+    TestCase11<R(A&&, ...) const volatile &,        1, Q_CV>::run();
+    TestCase11<R(A&&, A&&) &,                       2, Q_None>::run();
+    TestCase11<R(A&&, A&&) const &,                 2, Q_Const>::run();
+    TestCase11<R(A&&, A&&) volatile &,              2, Q_Volatile>::run();
+    TestCase11<R(A&&, A&&) const volatile &,        2, Q_CV>::run();
+    TestCase11<R(A&&, A&&, ...) &,                  2, Q_None>::run();
+    TestCase11<R(A&&, A&&, ...) const &,            2, Q_Const>::run();
+    TestCase11<R(A&&, A&&, ...) volatile &,         2, Q_Volatile>::run();
+    TestCase11<R(A&&, A&&, ...) const volatile &,   2, Q_CV>::run();
+    TestCase11<R() &&,                              0, Q_None, /* RValue */ true>::run();
+    TestCase11<R() const &&,                        0, Q_Const, /* RValue */ true>::run();
+    TestCase11<R() volatile &&,                     0, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R() const volatile &&,               0, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(...) &&,                           0, Q_None, /* RValue */ true>::run();
+    TestCase11<R(...) const &&,                     0, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(...) volatile &&,                  0, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(...) const volatile &&,            0, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&) &&,                           1, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&) const &&,                     1, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&) volatile &&,                  1, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&) const volatile &&,            1, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&, ...) &&,                      1, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&, ...) const &&,                1, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&, ...) volatile &&,             1, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&, ...) const volatile &&,       1, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&) &&,                      2, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&) const &&,                2, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&) volatile &&,             2, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&) const volatile &&,       2, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, ...) &&,                 2, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, ...) const &&,           2, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, ...) volatile &&,        2, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, ...) const volatile &&,  2, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&) &&,                 3, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&) const &&,           3, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&) volatile &&,        3, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&) const volatile &&,  3, Q_CV, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&, ...)  &&,                 3, Q_None, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&, ...)  const &&,           3, Q_Const, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&, ...)  volatile &&,        3, Q_Volatile, /* RValue */ true>::run();
+    TestCase11<R(A&&, A&&, A&&, ...)  const volatile &&,  3, Q_CV, /* RValue */ true>::run();
+
+    test_derived_from_ref_wrap();
+#endif
+}
\ No newline at end of file

Removed: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp?rev=266589&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp (removed)
@@ -1,318 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// INVOKE (f, t1, t2, ..., tN)
-
-//------------------------------------------------------------------------------
-// TESTING INVOKE(f, t1, t2, ..., tN)
-//   - Bullet 1 -- (t1.*f)(t2, ..., tN)
-//   - Bullet 2 -- ((*t1).*f)(t2, ..., tN)
-//
-// Overview:
-//    Bullets 1 and 2 handle the case where 'f' is a pointer to member function.
-//    Bullet 1 only handles the cases where t1 is an object of type T or a
-//    type derived from 'T'. Bullet 2 handles all other cases.
-//
-// Concerns:
-//   1) cv-qualified member function signatures are accepted.
-//   2) reference qualified member function signatures are accepted.
-//   3) member functions with varargs at the end are accepted.
-//   4) The arguments are perfect forwarded to the member function call.
-//   5) Classes that are publicly derived from 'T' are accepted as the call object
-//   6) All types that dereference to T or a type derived from T can be used
-//      as the call object.
-//   7) Pointers to T or a type derived from T can be used as the call object.
-//   8) Reference return types are properly deduced.
-//
-//
-// Plan:
-//   1) Create a class that contains a set, 'S', of non-static functions.
-//     'S' should include functions that cover every single combination
-//      of qualifiers and varargs for arities of 0, 1 and 2 (C-1,2,3).
-//      The argument types used in the functions should be non-copyable (C-4).
-//      The functions should return 'MethodID::setUncheckedCall()'.
-//
-//   2) Create a set of supported call object, 'Objs', of different types
-//      and behaviors. (C-5,6,7)
-//
-//   3) Attempt to call each function, 'f', in 'S' with each call object, 'c',
-//      in 'Objs'. After every attempted call to 'f' check that 'f' was
-//      actually called using 'MethodID::checkCalled(<return-value>)'
-//
-//       3b) If 'f' is reference qualified call 'f' with the properly qualified
-//       call object. Otherwise call 'f' with lvalue call objects.
-//
-//       3a) If 'f' is const, volatile, or cv qualified then call it with call
-//       objects that are equally or less cv-qualified.
-
-#include <functional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "invoke_helpers.h"
-
-//==============================================================================
-// MemFun03 - C++03 compatible set of test member functions.
-struct MemFun03 {
-    typedef void*& R;
-#define F(...) \
-    R f(__VA_ARGS__) { return MethodID<R(MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const { return MethodID<R(MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
-#
-    F()
-    F(...)
-    F(ArgType&)
-    F(ArgType&, ...)
-    F(ArgType&, ArgType&)
-    F(ArgType&, ArgType&, ...)
-    F(ArgType&, ArgType&, ArgType&)
-    F(ArgType&, ArgType&, ArgType&, ...)
-#undef F
-public:
-    MemFun03() {}
-private:
-    MemFun03(MemFun03 const&);
-    MemFun03& operator=(MemFun03 const&);
-};
-
-
-#if TEST_STD_VER >= 11
-
-//==============================================================================
-// MemFun11 - C++11 reference qualified test member functions.
-struct MemFun11 {
-    typedef void*& R;
-    typedef MemFun11 C;
-#define F(...) \
-    R f(__VA_ARGS__) & { return MethodID<R(C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const & { return MethodID<R(C::*)(__VA_ARGS__) const &>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) volatile & { return MethodID<R(C::*)(__VA_ARGS__) volatile &>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const volatile & { return MethodID<R(C::*)(__VA_ARGS__) const volatile &>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) && { return MethodID<R(C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const && { return MethodID<R(C::*)(__VA_ARGS__) const &&>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) volatile && { return MethodID<R(C::*)(__VA_ARGS__) volatile &&>::setUncheckedCall(); } \
-    R f(__VA_ARGS__) const volatile && { return MethodID<R(C::*)(__VA_ARGS__) const volatile &&>::setUncheckedCall(); }
-#
-    F()
-    F(...)
-    F(ArgType&&)
-    F(ArgType&&, ...)
-    F(ArgType&&, ArgType&&)
-    F(ArgType&&, ArgType&&, ...)
-    F(ArgType&&, ArgType&&, ArgType&&)
-    F(ArgType&&, ArgType&&, ArgType&&, ...)
-#undef F
-public:
-    MemFun11() {}
-private:
-    MemFun11(MemFun11 const&);
-    MemFun11& operator=(MemFun11 const&);
-};
-
-#endif // TEST_STD_VER >= 11
-
-
-//==============================================================================
-// TestCase - A test case for a single member function.
-//   ClassType - The type of the class being tested.
-//   CallSig   - The function signature of the method being tested.
-//   Arity     - the arity of 'CallSig'
-//   CV        - the cv qualifiers of 'CallSig' represented as a type tag.
-//   RValue    - The method is RValue qualified.
-//   ArgRValue - Call the method with RValue arguments.
-template <class ClassType, class CallSig, int Arity, class CV,
-          bool RValue = false, bool ArgRValue = false>
-struct TestCaseImp {
-public:
-
-    static void run() { TestCaseImp().doTest(); }
-
-private:
-    //==========================================================================
-    // TEST DISPATCH
-    void doTest() {
-         // (Plan-2) Create test call objects.
-        typedef ClassType T;
-        typedef DerivedFromType<T> D;
-        T obj;
-        T* obj_ptr = &obj;
-        D der;
-        D* der_ptr = &der;
-        DerefToType<T>   dref;
-        DerefPropType<T> dref2;
-
-         // (Plan-3) Dispatch based on the CV tags.
-        CV tag;
-        Bool<!RValue> NotRValue;
-        runTestDispatch(tag,  obj);
-        runTestDispatch(tag,  der);
-        runTestDispatch(tag, dref2);
-        runTestDispatchIf(NotRValue, tag,  dref);
-        runTestDispatchIf(NotRValue, tag,  obj_ptr);
-        runTestDispatchIf(NotRValue, tag, der_ptr);
-    }
-
-    template <class QT, class Tp>
-    void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
-        runTestDispatch(q, v);
-    }
-
-    template <class QT, class Tp>
-    void runTestDispatchIf(Bool<false>, QT, Tp&) {
-    }
-
-    template <class Tp>
-    void runTestDispatch(Q_None, Tp& v) {
-        runTest(v);
-    }
-
-    template <class Tp>
-    void runTestDispatch(Q_Const, Tp& v) {
-        Tp const& cv = v;
-        runTest(v);
-        runTest(cv);
-    }
-
-    template <class Tp>
-    void runTestDispatch(Q_Volatile, Tp& v) {
-        Tp volatile& vv = v;
-        runTest(v);
-        runTest(vv);
-    }
-
-    template <class Tp>
-    void runTestDispatch(Q_CV, Tp& v) {
-        Tp const& cv = v;
-        Tp volatile& vv = v;
-        Tp const volatile& cvv = v;
-        runTest(v);
-        runTest(cv);
-        runTest(vv);
-        runTest(cvv);
-    }
-
-    template <class Obj>
-    void runTest(Obj& obj) {
-        typedef Caster<Q_None, RValue> SCast;
-        typedef Caster<Q_None, ArgRValue> ACast;
-        typedef CallSig (ClassType::*MemPtr);
-        // Delegate test to logic in invoke_helpers.h
-        BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
-        b.runTest( (MemPtr)&ClassType::f, obj);
-    }
-};
-
-template <class Sig, int Arity, class CV>
-struct TestCase : public TestCaseImp<MemFun03, Sig, Arity, CV> {};
-
-#if TEST_STD_VER >= 11
-template <class Sig, int Arity, class CV, bool RValue = false>
-struct TestCase11 : public TestCaseImp<MemFun11, Sig, Arity, CV, RValue, true> {};
-#endif
-
-int main() {
-    typedef void*& R;
-    typedef ArgType A;
-    TestCase<R(),                                   0, Q_None>::run();
-    TestCase<R() const,                             0, Q_Const>::run();
-    TestCase<R() volatile,                          0, Q_Volatile>::run();
-    TestCase<R() const volatile,                    0, Q_CV>::run();
-    TestCase<R(...),                                0, Q_None>::run();
-    TestCase<R(...) const,                          0, Q_Const>::run();
-    TestCase<R(...) volatile,                       0, Q_Volatile>::run();
-    TestCase<R(...) const volatile,                 0, Q_CV>::run();
-    TestCase<R(A&),                                 1, Q_None>::run();
-    TestCase<R(A&) const,                           1, Q_Const>::run();
-    TestCase<R(A&) volatile,                        1, Q_Volatile>::run();
-    TestCase<R(A&) const volatile,                  1, Q_CV>::run();
-    TestCase<R(A&, ...),                            1, Q_None>::run();
-    TestCase<R(A&, ...) const,                      1, Q_Const>::run();
-    TestCase<R(A&, ...) volatile,                   1, Q_Volatile>::run();
-    TestCase<R(A&, ...) const volatile,             1, Q_CV>::run();
-    TestCase<R(A&, A&),                             2, Q_None>::run();
-    TestCase<R(A&, A&) const,                       2, Q_Const>::run();
-    TestCase<R(A&, A&) volatile,                    2, Q_Volatile>::run();
-    TestCase<R(A&, A&) const volatile,              2, Q_CV>::run();
-    TestCase<R(A&, A&, ...),                        2, Q_None>::run();
-    TestCase<R(A&, A&, ...) const,                  2, Q_Const>::run();
-    TestCase<R(A&, A&, ...) volatile,               2, Q_Volatile>::run();
-    TestCase<R(A&, A&, ...) const volatile,         2, Q_CV>::run();
-    TestCase<R(A&, A&, A&),                         3, Q_None>::run();
-    TestCase<R(A&, A&, A&) const,                   3, Q_Const>::run();
-    TestCase<R(A&, A&, A&) volatile,                3, Q_Volatile>::run();
-    TestCase<R(A&, A&, A&) const volatile,          3, Q_CV>::run();
-    TestCase<R(A&, A&, A&, ...),                    3, Q_None>::run();
-    TestCase<R(A&, A&, A&, ...) const,              3, Q_Const>::run();
-    TestCase<R(A&, A&, A&, ...) volatile,           3, Q_Volatile>::run();
-    TestCase<R(A&, A&, A&, ...) const volatile,     3, Q_CV>::run();
-
-#if TEST_STD_VER >= 11
-    TestCase11<R() &,                               0, Q_None>::run();
-    TestCase11<R() const &,                         0, Q_Const>::run();
-    TestCase11<R() volatile &,                      0, Q_Volatile>::run();
-    TestCase11<R() const volatile &,                0, Q_CV>::run();
-    TestCase11<R(...) &,                            0, Q_None>::run();
-    TestCase11<R(...) const &,                      0, Q_Const>::run();
-    TestCase11<R(...) volatile &,                   0, Q_Volatile>::run();
-    TestCase11<R(...) const volatile &,             0, Q_CV>::run();
-    TestCase11<R(A&&) &,                            1, Q_None>::run();
-    TestCase11<R(A&&) const &,                      1, Q_Const>::run();
-    TestCase11<R(A&&) volatile &,                   1, Q_Volatile>::run();
-    TestCase11<R(A&&) const volatile &,             1, Q_CV>::run();
-    TestCase11<R(A&&, ...) &,                       1, Q_None>::run();
-    TestCase11<R(A&&, ...) const &,                 1, Q_Const>::run();
-    TestCase11<R(A&&, ...) volatile &,              1, Q_Volatile>::run();
-    TestCase11<R(A&&, ...) const volatile &,        1, Q_CV>::run();
-    TestCase11<R(A&&, A&&) &,                       2, Q_None>::run();
-    TestCase11<R(A&&, A&&) const &,                 2, Q_Const>::run();
-    TestCase11<R(A&&, A&&) volatile &,              2, Q_Volatile>::run();
-    TestCase11<R(A&&, A&&) const volatile &,        2, Q_CV>::run();
-    TestCase11<R(A&&, A&&, ...) &,                  2, Q_None>::run();
-    TestCase11<R(A&&, A&&, ...) const &,            2, Q_Const>::run();
-    TestCase11<R(A&&, A&&, ...) volatile &,         2, Q_Volatile>::run();
-    TestCase11<R(A&&, A&&, ...) const volatile &,   2, Q_CV>::run();
-    TestCase11<R() &&,                              0, Q_None, /* RValue */ true>::run();
-    TestCase11<R() const &&,                        0, Q_Const, /* RValue */ true>::run();
-    TestCase11<R() volatile &&,                     0, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R() const volatile &&,               0, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(...) &&,                           0, Q_None, /* RValue */ true>::run();
-    TestCase11<R(...) const &&,                     0, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(...) volatile &&,                  0, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(...) const volatile &&,            0, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&) &&,                           1, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&) const &&,                     1, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&) volatile &&,                  1, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&) const volatile &&,            1, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&, ...) &&,                      1, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&, ...) const &&,                1, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&, ...) volatile &&,             1, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&, ...) const volatile &&,       1, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&) &&,                      2, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&) const &&,                2, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&) volatile &&,             2, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&) const volatile &&,       2, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, ...) &&,                 2, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, ...) const &&,           2, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, ...) volatile &&,        2, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, ...) const volatile &&,  2, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&) &&,                 3, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&) const &&,           3, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&) volatile &&,        3, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&) const volatile &&,  3, Q_CV, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&, ...)  &&,                 3, Q_None, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&, ...)  const &&,           3, Q_Const, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&, ...)  volatile &&,        3, Q_Volatile, /* RValue */ true>::run();
-    TestCase11<R(A&&, A&&, A&&, ...)  const volatile &&,  3, Q_CV, /* RValue */ true>::run();
-#endif
-}
\ No newline at end of file

Removed: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp?rev=266589&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp (removed)
@@ -1,164 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// INVOKE (f, t1, t2, ..., tN)
-
-//------------------------------------------------------------------------------
-// TESTING INVOKE(f, t1, t2, ..., tN)
-//   - Bullet 3 -- t1.*f
-//   - Bullet 4 -- (*t1).*f
-//
-// Overview:
-//    Bullets 3 and 4 handle the case where 'f' is a pointer to member object.
-//    Bullet 3 only handles the cases where t1 is an object of type T or a
-//    type derived from 'T'. Bullet 4 handles all other cases.
-//
-// Concerns:
-//   1) The return type is always an lvalue reference.
-//   2) The return type is not less cv-qualified that the object that contains it.
-//   3) The return type is not less cv-qualified than object type.
-//   4) The call object is perfectly forwarded.
-//   5) Classes that are publicly derived from 'T' are accepted as the call object
-//   6) All types that dereference to T or a type derived from T can be used
-//      as the call object.
-//   7) Pointers to T or a type derived from T can be used as the call object.
-
-#include <functional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "invoke_helpers.h"
-
-template <class Tp>
-struct TestMemberObject {
-    TestMemberObject() : object() {}
-    Tp object;
-private:
-    TestMemberObject(TestMemberObject const&);
-    TestMemberObject& operator=(TestMemberObject const&);
-};
-
-template <class ObjectType>
-struct TestCase {
-    public:
-
-    static void run() { TestCase().doTest(); }
-
-private:
-    typedef TestMemberObject<ObjectType> TestType;
-
-    //==========================================================================
-    // TEST DISPATCH
-    void doTest() {
-        typedef DerivedFromType<TestType> Derived;
-        TestType obj;
-        TestType* obj_ptr = &obj;
-        Derived der;
-        Derived* der_ptr = &der;
-        DerefToType<TestType>   dref;
-        DerefPropType<TestType> dref2;
-
-        {
-            typedef ObjectType (TestType::*MemPtr);
-            typedef ObjectType E;
-            MemPtr M = &TestType::object;
-            runTestDispatch<E>(M, obj, &obj.object);
-            runTestDispatch<E>(M, der, &der.object);
-            runTestDispatch<E>(M, dref2, &dref2.object.object);
-            runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
-            runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
-            runTestPointerDispatch<E>(M, dref, &dref.object.object);
-        }
-        {
-            typedef ObjectType const (TestType::*CMemPtr);
-            typedef ObjectType const E;
-            CMemPtr M = &TestType::object;
-            runTestDispatch<E>(M, obj, &obj.object);
-            runTestDispatch<E>(M, der, &der.object);
-            runTestDispatch<E>(M, dref2, &dref2.object.object);
-            runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
-            runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
-            runTestPointerDispatch<E>(M, dref, &dref.object.object);
-        }
-        {
-            typedef ObjectType volatile (TestType::*VMemPtr);
-            typedef ObjectType volatile E;
-            VMemPtr M = &TestType::object;
-            runTestDispatch<E>(M, obj,  &obj.object);
-            runTestDispatch<E>(M, der,  &der.object);
-            runTestDispatch<E>(M, dref2, &dref2.object.object);
-            runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
-            runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
-            runTestPointerDispatch<E>(M, dref,    &dref.object.object);
-        }
-        {
-            typedef ObjectType const volatile (TestType::*CVMemPtr);
-            typedef ObjectType const volatile E;
-            CVMemPtr M = &TestType::object;
-            runTestDispatch<E>(M, obj,   &obj.object);
-            runTestDispatch<E>(M, der,   &der.object);
-            runTestDispatch<E>(M, dref2, &dref2.object.object);
-            runTestPointerDispatch<E>(M, obj_ptr, &obj_ptr->object);
-            runTestPointerDispatch<E>(M, der_ptr, &der_ptr->object);
-            runTestPointerDispatch<E>(M, dref,    &dref.object.object);
-        }
-    }
-
-    template <class Expect, class Fn, class T>
-    void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
-        runTest<Expect &>              (M, C_<T&>(obj),                expect);
-        runTest<Expect const&>         (M, C_<T const&>(obj),          expect);
-        runTest<Expect volatile&>      (M, C_<T volatile&>(obj),       expect);
-        runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
-#if TEST_STD_VER >= 11
-        runTest<Expect&&>               (M, C_<T&&>(obj),                expect);
-        runTest<Expect const&&>         (M, C_<T const&&>(obj),          expect);
-        runTest<Expect volatile&&>      (M, C_<T volatile&&>(obj),       expect);
-        runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
-#endif
-    }
-
-    template <class Expect, class Fn, class T>
-    void runTestPointerDispatch(Fn M, T& obj, ObjectType* expect) {
-        runTest<Expect&>(M, C_<T &>(obj),               expect);
-        runTest<Expect&>(M, C_<T const&>(obj),          expect);
-        runTest<Expect&>(M, C_<T volatile&>(obj),       expect);
-        runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
-#if TEST_STD_VER >= 11
-        runTest<Expect&>(M, C_<T&&>(obj),                expect);
-        runTest<Expect&>(M, C_<T const&&>(obj),          expect);
-        runTest<Expect&>(M, C_<T volatile&&>(obj),       expect);
-        runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
-#endif
-    }
-
-    template <class Expect, class Fn, class T>
-#if TEST_STD_VER >= 11
-    void runTest(Fn M, T&& obj, ObjectType* expect) {
-#else
-    void runTest(Fn M, T& obj, ObjectType* expect ) {
-#endif
-        static_assert((std::is_same<
-            decltype(std::__invoke(M, std::forward<T>(obj))), Expect
-          >::value), "");
-        Expect e = std::__invoke(M, std::forward<T>(obj));
-        assert(&e == expect);
-    }
-};
-
-int main() {
-    TestCase<ArgType>::run();
-    TestCase<ArgType const>::run();
-    TestCase<ArgType volatile>::run();
-    TestCase<ArgType const volatile>::run();
-    TestCase<ArgType*>::run();
-}
\ No newline at end of file

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp?rev=266590&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp Mon Apr 18 01:17:30 2016
@@ -0,0 +1,205 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+//   - Bullet 4 -- t1.*f
+//   - Bullet 5 -- t1.get().*f // t1 is a reference wrapper.
+//   - Bullet 6 -- (*t1).*f
+//
+// Overview:
+//    Bullets 4, 5 and 6 handle the case where 'f' is a pointer to member object.
+//    Bullet 4 only handles the cases where t1 is an object of type T or a
+//    type derived from 'T'. Bullet 5 handles cases where 't1' is a reference_wrapper
+//     and bullet 6 handles all other cases.
+//
+// Concerns:
+//   1) The return type is always an lvalue reference.
+//   2) The return type is not less cv-qualified that the object that contains it.
+//   3) The return type is not less cv-qualified than object type.
+//   4) The call object is perfectly forwarded.
+//   5) Classes that are publicly derived from 'T' are accepted as the call object
+//   6) All types that dereference to T or a type derived from T can be used
+//      as the call object.
+//   7) Pointers to T or a type derived from T can be used as the call object.
+//   8) reference_wrapper's are properly unwrapped before invoking the function.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+template <class Tp>
+struct TestMemberObject {
+    TestMemberObject() : object() {}
+    Tp object;
+private:
+    TestMemberObject(TestMemberObject const&);
+    TestMemberObject& operator=(TestMemberObject const&);
+};
+
+template <class ObjectType>
+struct TestCase {
+    public:
+
+    static void run() { TestCase().doTest(); }
+
+private:
+    typedef TestMemberObject<ObjectType> TestType;
+
+    //==========================================================================
+    // TEST DISPATCH
+    void doTest() {
+        typedef DerivedFromType<TestType> Derived;
+        TestType obj;
+        TestType* obj_ptr = &obj;
+        Derived der;
+        Derived* der_ptr = &der;
+        DerefToType<TestType>   dref;
+        DerefPropType<TestType> dref2;
+        std::reference_wrapper<TestType> rref(obj);
+        std::reference_wrapper<Derived> drref(der);
+
+        {
+            typedef ObjectType (TestType::*MemPtr);
+            typedef ObjectType E;
+            MemPtr M = &TestType::object;
+            runTestDispatch<E>(M, obj, &obj.object);
+            runTestDispatch<E>(M, der, &der.object);
+            runTestDispatch<E>(M, dref2, &dref2.object.object);
+            runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+            runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+            runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+            runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+            runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+        }
+        {
+            typedef ObjectType const (TestType::*CMemPtr);
+            typedef ObjectType const E;
+            CMemPtr M = &TestType::object;
+            runTestDispatch<E>(M, obj, &obj.object);
+            runTestDispatch<E>(M, der, &der.object);
+            runTestDispatch<E>(M, dref2, &dref2.object.object);
+            runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+            runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+            runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+            runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+            runTestNoPropDispatch<E>(M, dref,    &dref.object.object);
+        }
+        {
+            typedef ObjectType volatile (TestType::*VMemPtr);
+            typedef ObjectType volatile E;
+            VMemPtr M = &TestType::object;
+            runTestDispatch<E>(M, obj,  &obj.object);
+            runTestDispatch<E>(M, der,  &der.object);
+            runTestDispatch<E>(M, dref2, &dref2.object.object);
+            runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+            runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+            runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+            runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+            runTestNoPropDispatch<E>(M, dref,    &dref.object.object);
+        }
+        {
+            typedef ObjectType const volatile (TestType::*CVMemPtr);
+            typedef ObjectType const volatile E;
+            CVMemPtr M = &TestType::object;
+            runTestDispatch<E>(M, obj,   &obj.object);
+            runTestDispatch<E>(M, der,   &der.object);
+            runTestDispatch<E>(M, dref2, &dref2.object.object);
+            runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+            runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+            runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+            runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+            runTestNoPropDispatch<E>(M, dref,    &dref.object.object);
+        }
+    }
+
+    template <class Expect, class Fn, class T>
+    void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
+        runTest<Expect &>              (M, C_<T&>(obj),                expect);
+        runTest<Expect const&>         (M, C_<T const&>(obj),          expect);
+        runTest<Expect volatile&>      (M, C_<T volatile&>(obj),       expect);
+        runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+        runTest<Expect&&>               (M, C_<T&&>(obj),                expect);
+        runTest<Expect const&&>         (M, C_<T const&&>(obj),          expect);
+        runTest<Expect volatile&&>      (M, C_<T volatile&&>(obj),       expect);
+        runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+    }
+
+    template <class Expect, class Fn, class T>
+    void runTestPropCVDispatch(Fn M, T& obj, ObjectType* expect) {
+        runTest<Expect &>              (M, obj,                     expect);
+        runTest<Expect const&>         (M, makeConst(obj),          expect);
+        runTest<Expect volatile&>      (M, makeVolatile(obj),       expect);
+        runTest<Expect const volatile&>(M, makeCV(obj),             expect);
+    }
+
+    template <class Expect, class Fn, class T>
+    void runTestNoPropDispatch(Fn M, T& obj, ObjectType* expect) {
+        runTest<Expect&>(M, C_<T &>(obj),               expect);
+        runTest<Expect&>(M, C_<T const&>(obj),          expect);
+        runTest<Expect&>(M, C_<T volatile&>(obj),       expect);
+        runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+        runTest<Expect&>(M, C_<T&&>(obj),                expect);
+        runTest<Expect&>(M, C_<T const&&>(obj),          expect);
+        runTest<Expect&>(M, C_<T volatile&&>(obj),       expect);
+        runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+    }
+
+    template <class Expect, class Fn, class T>
+    void runTest(Fn M, const T& obj, ObjectType* expect) {
+         static_assert((std::is_same<
+            decltype(std::__invoke(M, obj)), Expect
+          >::value), "");
+        Expect e = std::__invoke(M, obj);
+        assert(&e == expect);
+    }
+
+    template <class Expect, class Fn, class T>
+#if TEST_STD_VER >= 11
+    void runTest(Fn M, T&& obj, ObjectType* expect) {
+#else
+    void runTest(Fn M, T& obj, ObjectType* expect ) {
+#endif
+        static_assert((std::is_same<
+            decltype(std::__invoke(M, std::forward<T>(obj))), Expect
+          >::value), "");
+        Expect e = std::__invoke(M, std::forward<T>(obj));
+        assert(&e == expect);
+    }
+};
+
+
+
+
+int main() {
+    TestCase<ArgType>::run();
+    TestCase<ArgType const>::run();
+    TestCase<ArgType volatile>::run();
+    TestCase<ArgType const volatile>::run();
+    TestCase<ArgType*>::run();
+}
\ No newline at end of file

Removed: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp?rev=266589&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp (removed)
@@ -1,327 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// INVOKE (f, t1, t2, ..., tN)
-
-//------------------------------------------------------------------------------
-// TESTING INVOKE(f, t1, t2, ..., tN)
-//   - Bullet 5 -- f(t2, ..., tN)
-//
-// Overview:
-//    Bullet 5 handles the cases where the first argument is not a member
-//   function.
-//
-// Concerns:
-//   1) Different types of callable objects are supported. Including
-//      1a) Free Function pointers and references.
-//      1b) Classes which provide a call operator
-//      1c) lambdas
-//   2) The callable objects are perfect forwarded.
-//   3) The arguments are perfect forwarded.
-//   4) Signatures which include varargs are supported.
-//   5) In C++03 3 extra arguments should be allowed.
-//
-// Plan:
-//  1) Define a set of free functions, 'SF', and class types with call
-//     operators, 'SC', that address concerns 4 and 5. The free functions should
-//     return 'FunctionID::setUncheckedCall()' and the call operators should
-//     return 'MethodID::setUncheckedCall()'.
-//
-//  2) For each function 'f' in 'SF' and 'SC' attempt to call 'f'
-//     using the correct number of arguments and cv-ref qualifiers. Check that
-//     'f' has been called using 'FunctionID::checkCall()' if 'f' is a free
-//     function and 'MethodID::checkCall()' otherwise.
-
-
-
-#include <functional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "invoke_helpers.h"
-
-
-//==============================================================================
-// freeFunction03 - A C++03 free function.
-void*& freeFunction03() {
-    return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall();
-}
-
-void*& freeFunction03(...) {
-    return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall();
-}
-
-template <class A0>
-void*& freeFunction03(A0&) {
-    return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
-}
-
-
-template <class A0>
-void*& freeFunction03(A0&, ...) {
-    return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
-}
-
-template <class A0, class A1>
-void*& freeFunction03(A0&, A1&) {
-    return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
-}
-
-
-template <class A0, class A1>
-void*& freeFunction03(A0&, A1&, ...) {
-    return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
-}
-
-template <class A0, class A1, class A2>
-void*& freeFunction03(A0&, A1&, A2&) {
-    return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
-}
-
-template <class A0, class A1, class A2>
-void*& freeFunction03(A0&, A1&, A2&, ...) {
-    return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
-}
-
-//==============================================================================
-// Functor03 - C++03 compatible functor object
-struct Functor03 {
-    typedef void*& R;
-    typedef Functor03 C;
-#define F(Args, ...) \
-    __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
-    __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
-    __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
-    __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
-#
-    F(())
-    F((A0&), template <class A0>)
-    F((A0&, A1&), template <class A0, class A1>)
-    F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
-#undef F
-public:
-    Functor03() {}
-private:
-    Functor03(Functor03 const&);
-    Functor03& operator=(Functor03 const&);
-};
-
-
-#if TEST_STD_VER >= 11
-
-//==============================================================================
-// freeFunction11 - A C++11 free function.
-template <class ...Args>
-void*& freeFunction11(Args&&...) {
-    return FunctionPtrID<void*&(Args&&...), freeFunction11>::setUncheckedCall();
-}
-
-template <class ...Args>
-void*& freeFunction11(Args&&...,...) {
-    return FunctionPtrID<void*&(Args&&...,...), freeFunction11>::setUncheckedCall();
-}
-
-//==============================================================================
-// Functor11 - C++11 reference qualified test member functions.
-struct Functor11 {
-    typedef void*& R;
-    typedef Functor11 C;
-
-#define F(CV) \
-    template <class ...Args> \
-    R operator()(Args&&...) CV { return MethodID<R(C::*)(Args&&...) CV>::setUncheckedCall(); }
-#
-    F(&)
-    F(const &)
-    F(volatile &)
-    F(const volatile &)
-    F(&&)
-    F(const &&)
-    F(volatile &&)
-    F(const volatile &&)
-#undef F
-public:
-    Functor11() {}
-private:
-    Functor11(Functor11 const&);
-    Functor11& operator=(Functor11 const&);
-};
-
-#endif // TEST_STD_VER >= 11
-
-
-//==============================================================================
-// TestCaseFunctorImp - A test case for an operator() class method.
-//   ClassType - The type of the call object.
-//   CallSig   - The function signature of the call operator being tested.
-//   Arity     - the arity of 'CallSig'
-//   ObjCaster - Transformation function applied to call object.
-//   ArgCaster - Transformation function applied to the extra arguments.
-template <class ClassType, class CallSig, int Arity,
-          class ObjCaster, class ArgCaster = LValueCaster>
-struct TestCaseFunctorImp {
-public:
-    static void run() {
-        typedef MethodID<CallSig ClassType::*> MID;
-        BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
-        typedef ClassType T;
-        typedef DerivedFromType<T> D;
-        T obj;
-        D der;
-        t.runTest(obj);
-        t.runTest(der);
-    }
-};
-
-//==============================================================================
-// TestCaseFreeFunction - A test case for a free function.
-//   CallSig   - The function signature of the free function being tested.
-//   FnPtr     - The function being tested.
-//   Arity     - the arity of 'CallSig'
-//   ArgCaster - Transformation function to be applied to the extra arguments.
-template <class CallSig, CallSig* FnPtr, int Arity, class ArgCaster>
-struct TestCaseFreeFunction {
-public:
-    static void run() {
-        typedef FunctionPtrID<CallSig, FnPtr> FID;
-        BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
-
-        DerefToType<CallSig*> deref_to(FnPtr);
-        DerefToType<CallSig&> deref_to_ref(*FnPtr);
-
-        t.runTest(FnPtr);
-        t.runTest(*FnPtr);
-        t.runTest(deref_to);
-        t.runTest(deref_to_ref);
-    }
-};
-
-//==============================================================================
-//                          runTest Helpers
-//==============================================================================
-#if TEST_STD_VER >= 11
-template <class Sig, int Arity, class ArgCaster>
-void runFunctionTestCase11() {
-    TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
-}
-#endif
-
-template <class Sig, int Arity, class ArgCaster>
-void runFunctionTestCase() {
-    TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
-#if TEST_STD_VER >= 11
-    runFunctionTestCase11<Sig, Arity, ArgCaster>();
-#endif
-}
-
-template <class Sig, int Arity, class ObjCaster, class ArgCaster>
-void runFunctorTestCase() {
-    TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
-}
-
-template <class Sig, int Arity, class ObjCaster>
-void runFunctorTestCase() {
-    TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
-}
-
-#if TEST_STD_VER >= 11
-// runTestCase - Run a test case for C++11 class functor types
-template <class Sig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
-void runFunctorTestCase11() {
-    TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
-}
-#endif
-
-// runTestCase - Run a test case for both function and functor types.
-template <class Sig, int Arity, class ArgCaster>
-void runTestCase() {
-    runFunctionTestCase<Sig, Arity, ArgCaster>();
-    runFunctorTestCase <Sig, Arity, LValueCaster, ArgCaster>();
-};
-
-int main() {
-    typedef void*& R;
-    typedef ArgType A;
-    typedef A const CA;
-
-    runTestCase< R(),                                   0, LValueCaster      >();
-    runTestCase< R(A&),                                 1, LValueCaster      >();
-    runTestCase< R(A&, A&),                             2, LValueCaster      >();
-    runTestCase< R(A&, A&, A&),                         3, LValueCaster      >();
-    runTestCase< R(CA&),                                1, ConstCaster       >();
-    runTestCase< R(CA&, CA&),                           2, ConstCaster       >();
-    runTestCase< R(CA&, CA&, CA&),                      3, ConstCaster       >();
-
-    runFunctionTestCase<R(...),                         0, LValueCaster      >();
-    runFunctionTestCase<R(A&, ...),                     1, LValueCaster      >();
-    runFunctionTestCase<R(A&, A&, ...),                 2, LValueCaster      >();
-    runFunctionTestCase<R(A&, A&, A&, ...),             3, LValueCaster      >();
-
-#if TEST_STD_VER >= 11
-    runFunctionTestCase11<R(A&&),                       1, MoveCaster        >();
-    runFunctionTestCase11<R(A&&, ...),                  1, MoveCaster        >();
-#endif
-
-    runFunctorTestCase<R(),                             0, LValueCaster      >();
-    runFunctorTestCase<R() const,                       0, ConstCaster       >();
-    runFunctorTestCase<R() volatile,                    0, VolatileCaster    >();
-    runFunctorTestCase<R() const volatile,              0, CVCaster          >();
-    runFunctorTestCase<R(A&),                           1, LValueCaster      >();
-    runFunctorTestCase<R(A&) const,                     1, ConstCaster       >();
-    runFunctorTestCase<R(A&) volatile,                  1, VolatileCaster    >();
-    runFunctorTestCase<R(A&) const volatile,            1, CVCaster          >();
-    runFunctorTestCase<R(A&, A&),                       2, LValueCaster      >();
-    runFunctorTestCase<R(A&, A&) const,                 2, ConstCaster       >();
-    runFunctorTestCase<R(A&, A&) volatile,              2, VolatileCaster    >();
-    runFunctorTestCase<R(A&, A&) const volatile,        2, CVCaster          >();
-    runFunctorTestCase<R(A&, A&, A&),                   3, LValueCaster      >();
-    runFunctorTestCase<R(A&, A&, A&) const,             3, ConstCaster       >();
-    runFunctorTestCase<R(A&, A&, A&) volatile,          3, VolatileCaster    >();
-    runFunctorTestCase<R(A&, A&, A&) const volatile,    3, CVCaster          >();
-    {
-    typedef ConstCaster CC;
-    runFunctorTestCase<R(CA&),                          1, LValueCaster,   CC>();
-    runFunctorTestCase<R(CA&) const,                    1, ConstCaster,    CC>();
-    runFunctorTestCase<R(CA&) volatile,                 1, VolatileCaster, CC>();
-    runFunctorTestCase<R(CA&) const volatile,           1, CVCaster,       CC>();
-    runFunctorTestCase<R(CA&, CA&),                     2, LValueCaster,   CC>();
-    runFunctorTestCase<R(CA&, CA&) const,               2, ConstCaster,    CC>();
-    runFunctorTestCase<R(CA&, CA&) volatile,            2, VolatileCaster, CC>();
-    runFunctorTestCase<R(CA&, CA&) const volatile,      2, CVCaster,       CC>();
-    runFunctorTestCase<R(CA&, CA&, CA&),                3, LValueCaster,   CC>();
-    runFunctorTestCase<R(CA&, CA&, CA&) const,          3, ConstCaster,    CC>();
-    runFunctorTestCase<R(CA&, CA&, CA&) volatile,       3, VolatileCaster, CC>();
-    runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster,       CC>();
-    }
-
-#if TEST_STD_VER >= 11
-    runFunctorTestCase11<R() &,                    0, LValueCaster          >();
-    runFunctorTestCase11<R() const &,              0, ConstCaster           >();
-    runFunctorTestCase11<R() volatile &,           0, VolatileCaster        >();
-    runFunctorTestCase11<R() const volatile &,     0, CVCaster              >();
-    runFunctorTestCase11<R() &&,                   0, MoveCaster            >();
-    runFunctorTestCase11<R() const &&,             0, MoveConstCaster       >();
-    runFunctorTestCase11<R() volatile &&,          0, MoveVolatileCaster    >();
-    runFunctorTestCase11<R() const volatile &&,    0, MoveCVCaster          >();
-    {
-    typedef MoveCaster MC;
-    runFunctorTestCase11<R(A&&) &,                 1, LValueCaster,       MC>();
-    runFunctorTestCase11<R(A&&) const &,           1, ConstCaster,        MC>();
-    runFunctorTestCase11<R(A&&) volatile &,        1, VolatileCaster,     MC>();
-    runFunctorTestCase11<R(A&&) const volatile &,  1, CVCaster,           MC>();
-    runFunctorTestCase11<R(A&&) &&,                1, MoveCaster,         MC>();
-    runFunctorTestCase11<R(A&&) const &&,          1, MoveConstCaster,    MC>();
-    runFunctorTestCase11<R(A&&) volatile &&,       1, MoveVolatileCaster, MC>();
-    runFunctorTestCase11<R(A&&) const volatile &&, 1, MoveCVCaster,       MC>();
-    }
-#endif
-}

Added: libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp?rev=266590&view=auto
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp Mon Apr 18 01:17:30 2016
@@ -0,0 +1,327 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+//   - Bullet 7 -- f(t2, ..., tN)
+//
+// Overview:
+//    Bullet 7 handles the cases where the first argument is not a member
+//   function.
+//
+// Concerns:
+//   1) Different types of callable objects are supported. Including
+//      1a) Free Function pointers and references.
+//      1b) Classes which provide a call operator
+//      1c) lambdas
+//   2) The callable objects are perfect forwarded.
+//   3) The arguments are perfect forwarded.
+//   4) Signatures which include varargs are supported.
+//   5) In C++03 3 extra arguments should be allowed.
+//
+// Plan:
+//  1) Define a set of free functions, 'SF', and class types with call
+//     operators, 'SC', that address concerns 4 and 5. The free functions should
+//     return 'FunctionID::setUncheckedCall()' and the call operators should
+//     return 'MethodID::setUncheckedCall()'.
+//
+//  2) For each function 'f' in 'SF' and 'SC' attempt to call 'f'
+//     using the correct number of arguments and cv-ref qualifiers. Check that
+//     'f' has been called using 'FunctionID::checkCall()' if 'f' is a free
+//     function and 'MethodID::checkCall()' otherwise.
+
+
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+
+//==============================================================================
+// freeFunction03 - A C++03 free function.
+void*& freeFunction03() {
+    return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall();
+}
+
+void*& freeFunction03(...) {
+    return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0>
+void*& freeFunction03(A0&) {
+    return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0>
+void*& freeFunction03(A0&, ...) {
+    return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&) {
+    return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&, ...) {
+    return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&) {
+    return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&, ...) {
+    return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor03 - C++03 compatible functor object
+struct Functor03 {
+    typedef void*& R;
+    typedef Functor03 C;
+#define F(Args, ...) \
+    __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
+    __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
+    __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
+    __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
+#
+    F(())
+    F((A0&), template <class A0>)
+    F((A0&, A1&), template <class A0, class A1>)
+    F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
+#undef F
+public:
+    Functor03() {}
+private:
+    Functor03(Functor03 const&);
+    Functor03& operator=(Functor03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// freeFunction11 - A C++11 free function.
+template <class ...Args>
+void*& freeFunction11(Args&&...) {
+    return FunctionPtrID<void*&(Args&&...), freeFunction11>::setUncheckedCall();
+}
+
+template <class ...Args>
+void*& freeFunction11(Args&&...,...) {
+    return FunctionPtrID<void*&(Args&&...,...), freeFunction11>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor11 - C++11 reference qualified test member functions.
+struct Functor11 {
+    typedef void*& R;
+    typedef Functor11 C;
+
+#define F(CV) \
+    template <class ...Args> \
+    R operator()(Args&&...) CV { return MethodID<R(C::*)(Args&&...) CV>::setUncheckedCall(); }
+#
+    F(&)
+    F(const &)
+    F(volatile &)
+    F(const volatile &)
+    F(&&)
+    F(const &&)
+    F(volatile &&)
+    F(const volatile &&)
+#undef F
+public:
+    Functor11() {}
+private:
+    Functor11(Functor11 const&);
+    Functor11& operator=(Functor11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+//==============================================================================
+// TestCaseFunctorImp - A test case for an operator() class method.
+//   ClassType - The type of the call object.
+//   CallSig   - The function signature of the call operator being tested.
+//   Arity     - the arity of 'CallSig'
+//   ObjCaster - Transformation function applied to call object.
+//   ArgCaster - Transformation function applied to the extra arguments.
+template <class ClassType, class CallSig, int Arity,
+          class ObjCaster, class ArgCaster = LValueCaster>
+struct TestCaseFunctorImp {
+public:
+    static void run() {
+        typedef MethodID<CallSig ClassType::*> MID;
+        BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
+        typedef ClassType T;
+        typedef DerivedFromType<T> D;
+        T obj;
+        D der;
+        t.runTest(obj);
+        t.runTest(der);
+    }
+};
+
+//==============================================================================
+// TestCaseFreeFunction - A test case for a free function.
+//   CallSig   - The function signature of the free function being tested.
+//   FnPtr     - The function being tested.
+//   Arity     - the arity of 'CallSig'
+//   ArgCaster - Transformation function to be applied to the extra arguments.
+template <class CallSig, CallSig* FnPtr, int Arity, class ArgCaster>
+struct TestCaseFreeFunction {
+public:
+    static void run() {
+        typedef FunctionPtrID<CallSig, FnPtr> FID;
+        BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
+
+        DerefToType<CallSig*> deref_to(FnPtr);
+        DerefToType<CallSig&> deref_to_ref(*FnPtr);
+
+        t.runTest(FnPtr);
+        t.runTest(*FnPtr);
+        t.runTest(deref_to);
+        t.runTest(deref_to_ref);
+    }
+};
+
+//==============================================================================
+//                          runTest Helpers
+//==============================================================================
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase11() {
+    TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
+}
+#endif
+
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase() {
+    TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
+#if TEST_STD_VER >= 11
+    runFunctionTestCase11<Sig, Arity, ArgCaster>();
+#endif
+}
+
+template <class Sig, int Arity, class ObjCaster, class ArgCaster>
+void runFunctorTestCase() {
+    TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+
+template <class Sig, int Arity, class ObjCaster>
+void runFunctorTestCase() {
+    TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
+}
+
+#if TEST_STD_VER >= 11
+// runTestCase - Run a test case for C++11 class functor types
+template <class Sig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
+void runFunctorTestCase11() {
+    TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+#endif
+
+// runTestCase - Run a test case for both function and functor types.
+template <class Sig, int Arity, class ArgCaster>
+void runTestCase() {
+    runFunctionTestCase<Sig, Arity, ArgCaster>();
+    runFunctorTestCase <Sig, Arity, LValueCaster, ArgCaster>();
+};
+
+int main() {
+    typedef void*& R;
+    typedef ArgType A;
+    typedef A const CA;
+
+    runTestCase< R(),                                   0, LValueCaster      >();
+    runTestCase< R(A&),                                 1, LValueCaster      >();
+    runTestCase< R(A&, A&),                             2, LValueCaster      >();
+    runTestCase< R(A&, A&, A&),                         3, LValueCaster      >();
+    runTestCase< R(CA&),                                1, ConstCaster       >();
+    runTestCase< R(CA&, CA&),                           2, ConstCaster       >();
+    runTestCase< R(CA&, CA&, CA&),                      3, ConstCaster       >();
+
+    runFunctionTestCase<R(...),                         0, LValueCaster      >();
+    runFunctionTestCase<R(A&, ...),                     1, LValueCaster      >();
+    runFunctionTestCase<R(A&, A&, ...),                 2, LValueCaster      >();
+    runFunctionTestCase<R(A&, A&, A&, ...),             3, LValueCaster      >();
+
+#if TEST_STD_VER >= 11
+    runFunctionTestCase11<R(A&&),                       1, MoveCaster        >();
+    runFunctionTestCase11<R(A&&, ...),                  1, MoveCaster        >();
+#endif
+
+    runFunctorTestCase<R(),                             0, LValueCaster      >();
+    runFunctorTestCase<R() const,                       0, ConstCaster       >();
+    runFunctorTestCase<R() volatile,                    0, VolatileCaster    >();
+    runFunctorTestCase<R() const volatile,              0, CVCaster          >();
+    runFunctorTestCase<R(A&),                           1, LValueCaster      >();
+    runFunctorTestCase<R(A&) const,                     1, ConstCaster       >();
+    runFunctorTestCase<R(A&) volatile,                  1, VolatileCaster    >();
+    runFunctorTestCase<R(A&) const volatile,            1, CVCaster          >();
+    runFunctorTestCase<R(A&, A&),                       2, LValueCaster      >();
+    runFunctorTestCase<R(A&, A&) const,                 2, ConstCaster       >();
+    runFunctorTestCase<R(A&, A&) volatile,              2, VolatileCaster    >();
+    runFunctorTestCase<R(A&, A&) const volatile,        2, CVCaster          >();
+    runFunctorTestCase<R(A&, A&, A&),                   3, LValueCaster      >();
+    runFunctorTestCase<R(A&, A&, A&) const,             3, ConstCaster       >();
+    runFunctorTestCase<R(A&, A&, A&) volatile,          3, VolatileCaster    >();
+    runFunctorTestCase<R(A&, A&, A&) const volatile,    3, CVCaster          >();
+    {
+    typedef ConstCaster CC;
+    runFunctorTestCase<R(CA&),                          1, LValueCaster,   CC>();
+    runFunctorTestCase<R(CA&) const,                    1, ConstCaster,    CC>();
+    runFunctorTestCase<R(CA&) volatile,                 1, VolatileCaster, CC>();
+    runFunctorTestCase<R(CA&) const volatile,           1, CVCaster,       CC>();
+    runFunctorTestCase<R(CA&, CA&),                     2, LValueCaster,   CC>();
+    runFunctorTestCase<R(CA&, CA&) const,               2, ConstCaster,    CC>();
+    runFunctorTestCase<R(CA&, CA&) volatile,            2, VolatileCaster, CC>();
+    runFunctorTestCase<R(CA&, CA&) const volatile,      2, CVCaster,       CC>();
+    runFunctorTestCase<R(CA&, CA&, CA&),                3, LValueCaster,   CC>();
+    runFunctorTestCase<R(CA&, CA&, CA&) const,          3, ConstCaster,    CC>();
+    runFunctorTestCase<R(CA&, CA&, CA&) volatile,       3, VolatileCaster, CC>();
+    runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster,       CC>();
+    }
+
+#if TEST_STD_VER >= 11
+    runFunctorTestCase11<R() &,                    0, LValueCaster          >();
+    runFunctorTestCase11<R() const &,              0, ConstCaster           >();
+    runFunctorTestCase11<R() volatile &,           0, VolatileCaster        >();
+    runFunctorTestCase11<R() const volatile &,     0, CVCaster              >();
+    runFunctorTestCase11<R() &&,                   0, MoveCaster            >();
+    runFunctorTestCase11<R() const &&,             0, MoveConstCaster       >();
+    runFunctorTestCase11<R() volatile &&,          0, MoveVolatileCaster    >();
+    runFunctorTestCase11<R() const volatile &&,    0, MoveCVCaster          >();
+    {
+    typedef MoveCaster MC;
+    runFunctorTestCase11<R(A&&) &,                 1, LValueCaster,       MC>();
+    runFunctorTestCase11<R(A&&) const &,           1, ConstCaster,        MC>();
+    runFunctorTestCase11<R(A&&) volatile &,        1, VolatileCaster,     MC>();
+    runFunctorTestCase11<R(A&&) const volatile &,  1, CVCaster,           MC>();
+    runFunctorTestCase11<R(A&&) &&,                1, MoveCaster,         MC>();
+    runFunctorTestCase11<R(A&&) const &&,          1, MoveConstCaster,    MC>();
+    runFunctorTestCase11<R(A&&) volatile &&,       1, MoveVolatileCaster, MC>();
+    runFunctorTestCase11<R(A&&) const volatile &&, 1, MoveCVCaster,       MC>();
+    }
+#endif
+}

Modified: libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h Mon Apr 18 01:17:30 2016
@@ -79,6 +79,40 @@ typedef Caster<Q_Const,    true> MoveCon
 typedef Caster<Q_Volatile, true> MoveVolatileCaster;
 typedef Caster<Q_CV,       true> MoveCVCaster;
 
+
+template <class Tp>
+Tp const& makeConst(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp const* makeConst(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<const Tp> makeConst(std::reference_wrapper<Tp>& ref) {
+    return std::reference_wrapper<const Tp>(ref.get());
+}
+
+template <class Tp>
+Tp volatile& makeVolatile(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp volatile* makeVolatile(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<volatile Tp> makeVolatile(std::reference_wrapper<Tp>& ref) {
+    return std::reference_wrapper<volatile Tp>(ref.get());
+}
+
+template <class Tp>
+Tp const volatile& makeCV(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp const volatile* makeCV(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<const volatile Tp> makeCV(std::reference_wrapper<Tp>& ref) {
+    return std::reference_wrapper<const volatile Tp>(ref.get());
+}
+
 // A shorter name for 'static_cast'
 template <class QualType, class Tp>
 QualType C_(Tp& v) { return static_cast<QualType>(v); };

Modified: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp Mon Apr 18 01:17:30 2016
@@ -13,6 +13,7 @@
 
 #include <type_traits>
 #include <memory>
+#include <cassert>
 #include "test_macros.h"
 
 struct S
@@ -25,6 +26,11 @@ struct S
     double const volatile& operator()(char, int&) const volatile;
 };
 
+
+struct SD : public S { };
+
+struct NotDerived {};
+
 template <class Tp>
 struct Voider {
     typedef void type;
@@ -52,6 +58,7 @@ void test_no_result()
 
 int main()
 {
+    typedef NotDerived ND;
     { // functor object
     test_result_of<S(int), short> ();
     test_result_of<S&(unsigned char, int&), double> ();
@@ -90,32 +97,64 @@ int main()
     typedef int         (S::*PMS0)();
     typedef int*        (S::*PMS1)(long);
     typedef int&        (S::*PMS2)(long, int);
-    test_result_of<PMS0(               S),   int> ();
-    test_result_of<PMS0(               S&),  int> ();
-    test_result_of<PMS0(               S*),  int> ();
-    test_result_of<PMS0(               S*&), int> ();
-    test_result_of<PMS0(std::unique_ptr<S>), int> ();
+    test_result_of<PMS0(                             S),   int> ();
+    test_result_of<PMS0(                             S&),  int> ();
+    test_result_of<PMS0(                             S*),  int> ();
+    test_result_of<PMS0(                             S*&), int> ();
+    test_result_of<PMS0(      std::reference_wrapper<S>),  int> ();
+    test_result_of<PMS0(const std::reference_wrapper<S>&), int> ();
+    test_result_of<PMS0(      std::reference_wrapper<SD>),  int> ();
+    test_result_of<PMS0(const std::reference_wrapper<SD>&), int> ();
+    test_result_of<PMS0(std::unique_ptr<S>),  int> ();
+    test_result_of<PMS0(std::unique_ptr<SD>), int> ();
     test_no_result<PMS0(const          S&)>();
     test_no_result<PMS0(volatile       S&)>();
     test_no_result<PMS0(const volatile S&)>();
-
-    test_result_of<PMS1(               S,   int), int*> ();
-    test_result_of<PMS1(               S&,  int), int*> ();
-    test_result_of<PMS1(               S*,  int), int*> ();
-    test_result_of<PMS1(               S*&, int), int*> ();
-    test_result_of<PMS1(std::unique_ptr<S>, int), int*> ();
+    test_no_result<PMS0(ND &                           )>();
+    test_no_result<PMS0(const ND&                      )>();
+    test_no_result<PMS0(std::unique_ptr<S const>       )>();
+    test_no_result<PMS0(std::reference_wrapper<S const>)>();
+    test_no_result<PMS0(std::reference_wrapper<ND>     )>();
+    test_no_result<PMS0(std::unique_ptr<ND>            )>();
+
+    test_result_of<PMS1(                             S,   int), int*> ();
+    test_result_of<PMS1(                             S&,  int), int*> ();
+    test_result_of<PMS1(                             S*,  int), int*> ();
+    test_result_of<PMS1(                             S*&, int), int*> ();
+    test_result_of<PMS1(std::unique_ptr<S>,               int), int*> ();
+    test_result_of<PMS1(std::unique_ptr<SD>,              int), int*> ();
+    test_result_of<PMS1(std::reference_wrapper<S>,        int), int*> ();
+    test_result_of<PMS1(const std::reference_wrapper<S>&, int), int*> ();
+    test_result_of<PMS1(std::reference_wrapper<SD>,        int), int*> ();
+    test_result_of<PMS1(const std::reference_wrapper<SD>&, int), int*> ();
     test_no_result<PMS1(const          S&, int)>();
     test_no_result<PMS1(volatile       S&, int)>();
     test_no_result<PMS1(const volatile S&, int)>();
+    test_no_result<PMS1(ND &,                            int)>();
+    test_no_result<PMS1(const ND&,                       int)>();
+    test_no_result<PMS1(std::unique_ptr<S const>,        int)>();
+    test_no_result<PMS1(std::reference_wrapper<S const>, int)>();
+    test_no_result<PMS1(std::reference_wrapper<ND>,      int)>();
+    test_no_result<PMS1(std::unique_ptr<ND>,             int)>();
 
     test_result_of<PMS2(               S,   int, int), int&> ();
     test_result_of<PMS2(               S&,  int, int), int&> ();
     test_result_of<PMS2(               S*,  int, int), int&> ();
     test_result_of<PMS2(               S*&, int, int), int&> ();
     test_result_of<PMS2(std::unique_ptr<S>, int, int), int&> ();
+    test_result_of<PMS2(std::unique_ptr<SD>, int, int), int&> ();
+    test_result_of<PMS2(std::reference_wrapper<S>,         int, int), int&> ();
+    test_result_of<PMS2(const std::reference_wrapper<S>&,  int, int), int&> ();
+    test_result_of<PMS2(std::reference_wrapper<SD>,        int, int), int&> ();
+    test_result_of<PMS2(const std::reference_wrapper<SD>&, int, int), int&> ();
     test_no_result<PMS2(const          S&, int, int)>();
     test_no_result<PMS2(volatile       S&, int, int)>();
     test_no_result<PMS2(const volatile S&, int, int)>();
+    test_no_result<PMS2(std::unique_ptr<S const>,   int, int)>();
+    test_no_result<PMS2(std::reference_wrapper<S const>, int, int)>();
+    test_no_result<PMS2(const ND&,                  int, int)>();
+    test_no_result<PMS2(std::reference_wrapper<ND>, int, int)>();
+    test_no_result<PMS2(std::unique_ptr<ND>,        int, int)>();
 
     typedef int        (S::*PMS0C)() const;
     typedef int*       (S::*PMS1C)(long) const;
@@ -128,6 +167,15 @@ int main()
     test_result_of<PMS0C(               S*&), int> ();
     test_result_of<PMS0C(const          S*&), int> ();
     test_result_of<PMS0C(std::unique_ptr<S>), int> ();
+    test_result_of<PMS0C(std::unique_ptr<SD>), int> ();
+    test_result_of<PMS0C(std::reference_wrapper<S>              ), int> ();
+    test_result_of<PMS0C(std::reference_wrapper<const S>        ), int> ();
+    test_result_of<PMS0C(const std::reference_wrapper<S> &      ), int> ();
+    test_result_of<PMS0C(const std::reference_wrapper<const S> &), int> ();
+    test_result_of<PMS0C(std::reference_wrapper<SD>             ), int> ();
+    test_result_of<PMS0C(std::reference_wrapper<const SD>       ), int> ();
+    test_result_of<PMS0C(const std::reference_wrapper<SD> &     ), int> ();
+    test_result_of<PMS0C(const std::reference_wrapper<const SD> &), int> ();
     test_no_result<PMS0C(volatile       S&)>();
     test_no_result<PMS0C(const volatile S&)>();
 
@@ -248,5 +296,16 @@ int main()
     test_result_of<PMD(volatile S*), volatile char&> ();
     test_result_of<PMD(const volatile S&), const volatile char&> ();
     test_result_of<PMD(const volatile S*), const volatile char&> ();
+    test_result_of<PMD(SD&), char &>();
+    test_result_of<PMD(SD const&), const char&>();
+    test_result_of<PMD(SD*), char&>();
+    test_result_of<PMD(const SD*), const char&>();
+    test_result_of<PMD(std::unique_ptr<S>), char &>();
+    test_result_of<PMD(std::unique_ptr<S const>), const char&>();
+#if TEST_STD_VER >= 11
+    test_result_of<PMD(std::reference_wrapper<S>), char&>();
+    test_result_of<PMD(std::reference_wrapper<S const>), const char&>();
+#endif
+    test_no_result<PMD(ND&)>();
     }
 }

Modified: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp Mon Apr 18 01:17:30 2016
@@ -14,6 +14,8 @@
 // result_of<Fn(ArgTypes...)>
 
 #include <type_traits>
+#include <memory>
+#include <utility>
 #include "test_macros.h"
 
 struct wat
@@ -23,6 +25,8 @@ struct wat
 };
 
 struct F {};
+struct FD : public F {};
+struct NotDerived {};
 
 template <class T, class U>
 void test_result_of_imp()
@@ -35,6 +39,7 @@ void test_result_of_imp()
 
 int main()
 {
+    typedef NotDerived ND;
     {
     typedef char F::*PMD;
     test_result_of_imp<PMD(F                &), char                &>();
@@ -51,6 +56,31 @@ int main()
     test_result_of_imp<PMD(F const          ), char &&>();
     test_result_of_imp<PMD(F volatile       ), char &&>();
     test_result_of_imp<PMD(F const volatile ), char &&>();
+
+    test_result_of_imp<PMD(FD                &), char                &>();
+    test_result_of_imp<PMD(FD const          &), char const          &>();
+    test_result_of_imp<PMD(FD volatile       &), char volatile       &>();
+    test_result_of_imp<PMD(FD const volatile &), char const volatile &>();
+
+    test_result_of_imp<PMD(FD                &&), char                &&>();
+    test_result_of_imp<PMD(FD const          &&), char const          &&>();
+    test_result_of_imp<PMD(FD volatile       &&), char volatile       &&>();
+    test_result_of_imp<PMD(FD const volatile &&), char const volatile &&>();
+
+    test_result_of_imp<PMD(FD                ), char &&>();
+    test_result_of_imp<PMD(FD const          ), char &&>();
+    test_result_of_imp<PMD(FD volatile       ), char &&>();
+    test_result_of_imp<PMD(FD const volatile ), char &&>();
+
+    test_result_of_imp<PMD(std::unique_ptr<F>),        char &>();
+    test_result_of_imp<PMD(std::unique_ptr<F const>),  const char &>();
+    test_result_of_imp<PMD(std::unique_ptr<FD>),       char &>();
+    test_result_of_imp<PMD(std::unique_ptr<FD const>), const char &>();
+
+    test_result_of_imp<PMD(std::reference_wrapper<F>),        char &>();
+    test_result_of_imp<PMD(std::reference_wrapper<F const>),  const char &>();
+    test_result_of_imp<PMD(std::reference_wrapper<FD>),       char &>();
+    test_result_of_imp<PMD(std::reference_wrapper<FD const>), const char &>();
     }
     {
     test_result_of_imp<int (F::* (F       &)) ()                &, int> ();
@@ -83,6 +113,42 @@ int main()
     test_result_of_imp<int (F::* (F volatile )) () const volatile &&, int> ();
     test_result_of_imp<int (F::* (F const volatile )) () const volatile &&, int> ();
     }
-
+    {
+    test_result_of_imp<int (F::* (FD       &)) ()                &, int> ();
+    test_result_of_imp<int (F::* (FD       &)) () const          &, int> ();
+    test_result_of_imp<int (F::* (FD       &)) () volatile       &, int> ();
+    test_result_of_imp<int (F::* (FD       &)) () const volatile &, int> ();
+    test_result_of_imp<int (F::* (FD const &)) () const          &, int> ();
+    test_result_of_imp<int (F::* (FD const &)) () const volatile &, int> ();
+    test_result_of_imp<int (F::* (FD volatile &)) () volatile       &, int> ();
+    test_result_of_imp<int (F::* (FD volatile &)) () const volatile &, int> ();
+    test_result_of_imp<int (F::* (FD const volatile &)) () const volatile &, int> ();
+
+    test_result_of_imp<int (F::* (FD       &&)) ()                &&, int> ();
+    test_result_of_imp<int (F::* (FD       &&)) () const          &&, int> ();
+    test_result_of_imp<int (F::* (FD       &&)) () volatile       &&, int> ();
+    test_result_of_imp<int (F::* (FD       &&)) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD const &&)) () const          &&, int> ();
+    test_result_of_imp<int (F::* (FD const &&)) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD volatile &&)) () volatile       &&, int> ();
+    test_result_of_imp<int (F::* (FD volatile &&)) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD const volatile &&)) () const volatile &&, int> ();
+
+    test_result_of_imp<int (F::* (FD       )) ()                &&, int> ();
+    test_result_of_imp<int (F::* (FD       )) () const          &&, int> ();
+    test_result_of_imp<int (F::* (FD       )) () volatile       &&, int> ();
+    test_result_of_imp<int (F::* (FD       )) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD const )) () const          &&, int> ();
+    test_result_of_imp<int (F::* (FD const )) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD volatile )) () volatile       &&, int> ();
+    test_result_of_imp<int (F::* (FD volatile )) () const volatile &&, int> ();
+    test_result_of_imp<int (F::* (FD const volatile )) () const volatile &&, int> ();
+    }
+    {
+    test_result_of_imp<int (F::* (std::reference_wrapper<F>))       (),       int>();
+    test_result_of_imp<int (F::* (std::reference_wrapper<const F>)) () const, int>();
+    test_result_of_imp<int (F::* (std::unique_ptr<F>       ))       (),       int>();
+    test_result_of_imp<int (F::* (std::unique_ptr<const F> ))       () const, int>();
+    }
     test_result_of_imp<decltype(&wat::foo)(wat), void>();
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=266590&r1=266589&r2=266590&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Apr 18 01:17:30 2016
@@ -172,7 +172,7 @@
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2133">2133</a></td><td>Attitude to overloaded comma for iterators</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2156">2156</a></td><td>Unordered containers' <tt>reserve(n)</tt> reserves for <tt>n-1</tt> elements</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2218">2218</a></td><td>Unclear how containers use <tt>allocator_traits::construct()</tt></td><td>Kona</td><td></td></tr>
-	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2219">2219</a></td><td><tt><i>INVOKE</i></tt>-ing a pointer to member with a <tt>reference_wrapper</tt> as the object expression</td><td>Kona</td><td></td></tr>
+	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2219">2219</a></td><td><tt><i>INVOKE</i></tt>-ing a pointer to member with a <tt>reference_wrapper</tt> as the object expression</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2224">2224</a></td><td>Ambiguous status of access to non-live objects</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2234">2234</a></td><td><tt>assert()</tt> should allow usage in constant expressions</td><td>Kona</td><td>Complete</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2244">2244</a></td><td>Issue on <tt>basic_istream::seekg</tt></td><td>Kona</td><td>Complete</td></tr>




More information about the cfe-commits mailing list