[libcxx-commits] [PATCH] D80071: [NFC] Add _EnableIfLValueCallable and move reference out of __callable.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 16 15:53:37 PDT 2020


zoecarver created this revision.
zoecarver added a reviewer: ldionne.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
zoecarver added a comment.

Some references:

- The original suggestion. <https://reviews.llvm.org/D62928#2031628>
- The relevant section of the standard. <https://eel.is/c++draft/function.objects#func.wrap.func.con-7>
- The relevant CppReference link. <https://en.cppreference.com/w/cpp/utility/functional/function/function>


In std::functional moves the reference out of the `__callable` implementation and replaces `_EnableIfCallable` with `_EnableIfLValueCallable` (`_EnableIfLValueCallable` passes `__callable` an lvalue reference type).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80071

Files:
  libcxx/include/functional


Index: libcxx/include/functional
===================================================================
--- libcxx/include/functional
+++ libcxx/include/functional
@@ -2338,14 +2338,14 @@
 
     template <class _Fp, bool = _And<
         _IsNotSame<__uncvref_t<_Fp>, function>,
-        __invokable<_Fp&, _ArgTypes...>
+        __invokable<_Fp, _ArgTypes...>
     >::value>
     struct __callable;
     template <class _Fp>
         struct __callable<_Fp, true>
         {
             static const bool value = is_same<void, _Rp>::value ||
-                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
+                is_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
                                _Rp>::value;
         };
     template <class _Fp>
@@ -2355,7 +2355,7 @@
         };
 
   template <class _Fp>
-  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
+  using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type;
 public:
     typedef _Rp result_type;
 
@@ -2366,7 +2366,7 @@
     function(nullptr_t) _NOEXCEPT {}
     function(const function&);
     function(function&&) _NOEXCEPT;
-    template<class _Fp, class = _EnableIfCallable<_Fp>>
+    template<class _Fp, class = _EnableIfLValueCallable<_Fp>>
     function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -2380,14 +2380,14 @@
       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 = _EnableIfLValueCallable<_Fp>>
       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<typename decay<_Fp>::type>>
+    template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>>
     function& operator=(_Fp&&);
 
     ~function();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80071.264458.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200516/69ce89b4/attachment.bin>


More information about the libcxx-commits mailing list