Revert "Fix PR34298 - Allow std::function with an incomplete return type."

This reverts commit r312890 because the test case fails to compile for
older versions of Clang that reject initializing a const object without
a user defined constructor.

Since this patch should go into 5.0.1, I want to keep it an atomic change,
and will re-commit it with a fixed test case.

llvm-svn: 312891
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 85cde7d2f410353ee5c143ad931da571e9be11bf
diff --git a/include/functional b/include/functional
index f73c3ca..83a2e5a 100644
--- a/include/functional
+++ b/include/functional
@@ -1597,11 +1597,9 @@
       return reinterpret_cast<__base*>(p);
     }
 
-    template <class _Fp, bool = __lazy_and<
-        integral_constant<bool, !is_same<__uncvref_t<_Fp>, function>::value>,
-        __invokable<_Fp&, _ArgTypes...>
-    >::value>
-    struct __callable;
+    template <class _Fp, bool = !is_same<_Fp, function>::value &&
+                                __invokable<_Fp&, _ArgTypes...>::value>
+        struct __callable;
     template <class _Fp>
         struct __callable<_Fp, true>
         {
@@ -1614,9 +1612,6 @@
         {
             static const bool value = false;
         };
-
-  template <class _Fp>
-  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
 public:
     typedef _Rp result_type;
 
@@ -1627,7 +1622,9 @@
     function(nullptr_t) _NOEXCEPT : __f_(0) {}
     function(const function&);
     function(function&&) _NOEXCEPT;
-    template<class _Fp, class = _EnableIfCallable<_Fp>>
+    template<class _Fp, class = typename enable_if<
+        __callable<_Fp>::value && !is_same<_Fp, function>::value
+    >::type>
     function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -1641,15 +1638,21 @@
       function(allocator_arg_t, const _Alloc&, const function&);
     template<class _Alloc>
       function(allocator_arg_t, const _Alloc&, function&&);
-    template<class _Fp, class _Alloc, class = _EnableIfCallable<_Fp>>
+    template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
       function(allocator_arg_t, const _Alloc& __a, _Fp __f);
 #endif
 
     function& operator=(const function&);
     function& operator=(function&&) _NOEXCEPT;
     function& operator=(nullptr_t) _NOEXCEPT;
-    template<class _Fp, class = _EnableIfCallable<_Fp>>
-    function& operator=(_Fp&&);
+    template<class _Fp>
+      typename enable_if
+      <
+        __callable<typename decay<_Fp>::type>::value &&
+        !is_same<typename remove_reference<_Fp>::type, function>::value,
+        function&
+      >::type
+      operator=(_Fp&&);
 
     ~function();
 
@@ -1851,8 +1854,13 @@
 }
 
 template<class _Rp, class ..._ArgTypes>
-template <class _Fp, class>
-function<_Rp(_ArgTypes...)>&
+template <class _Fp>
+typename enable_if
+<
+    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
+    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
+    function<_Rp(_ArgTypes...)>&
+>::type
 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 {
     function(_VSTD::forward<_Fp>(__f)).swap(*this);