[libcxx-commits] [PATCH] D54410: [libc++] Add C++17 deduction guides for std::function
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 28 11:45:54 PST 2019
ldionne marked 2 inline comments as done.
ldionne added inline comments.
================
Comment at: libcxx/include/functional:1704
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_DEDUCTION_GUIDES)
+template<class _Rp, class ..._Ap>
----------------
mclow.lists wrote:
> In the rest of the library we just check for `_LIBCPP_HAS_NO_DEDUCTION_GUIDES`, trusting that it is set correctly.
> #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
>
The reason I'm checking whether C++ > 14 here is that in the future it's possible for new deduction guides to be added after C++17, and we'd only want to enable those in C++ > XX. For example, if we added new deduction guides in C++20, we'd want to say:
```
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_DEDUCTION_GUIDES
```
I wrote it that way for consistency with this pattern. WDYT?
================
Comment at: libcxx/include/functional:1711-1745
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
----------------
mclow.lists wrote:
> ldionne wrote:
> > Do we have something similar elsewhere I could reuse? This is ugly :(
> Can you use `__member_pointer_traits_imp` (in type_traits)?
`__member_pointer_traits_imp` does not handle `noexcept`, and it handles C-style variadics (it's not clear to me whether this is supported by the deduction guides, see http://eel.is/c++draft/func.wrap#func.con-12).
If it's OK to
- add `noexcept` support to `__member_pointer_traits_imp` (which means that `result_of` would work with `noexcept`-qualified functions, and
- support C-style variadics in the deduction guide for `std::function`
then we could add support for `noexcept` to `__member_pointer_traits_imp` and use the following instead:
```
template<class _Fp, class _Stripped = typename __member_pointer_traits<decltype(&_Fp::operator())>::_FnType>
function(_Fp) -> function<_Stripped>;
```
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54410/new/
https://reviews.llvm.org/D54410
More information about the libcxx-commits
mailing list