[libcxx-commits] [PATCH] D74351: [libcxx][type_traits] Implement C++20 common_ref
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 10 12:04:23 PST 2021
ldionne added inline comments.
================
Comment at: libcxx/include/type_traits:2306-2307
+template <class _Tp, class _Up>
+struct __common_reference2<_Tp&, _Up&&, enable_if_t<
+ is_convertible_v<_Up&&, __ll_common_ref<const _Up, _Tp>>>>
+{
----------------
cjdb wrote:
> miscco wrote:
> > cjdb wrote:
> > > miscco wrote:
> > > > cjdb wrote:
> > > > > Perhaps we should hold off on merging this so we can use `std::convertible_to` instead.
> > > > I would add that `std::convertible_to` has slightly different semantics too as it has some addtional requires clauses
> > > Fair. I'd at least encourage the use of a _requires-clause_, since it's demonstrably faster to compile than SFINAE and is being commit for the first time to a concepts-aware compiler.
> > That sounds reasonable. However, someone could theoretically use a C++20 compiler (aka clang 9) without concept support and that would lead to `<type_traits>` not compiling.
> >
> > On the other hand I think that is a very bad use case that should not be suported. Maintainers thoughts?
> >
> Since `common_reference` is really only useful with ranges in mind, we could section this code off with feature-test macros?
> On the other hand I think that is a very bad use case that should not be suported. Maintainers thoughts?
I think it's entirely fine to use requires clauses if it simplifies the implementation. I have little sympathy for someone trying to use this with a compiler that doesn't support concepts, or with a compiler that does but with concepts disabled.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74351/new/
https://reviews.llvm.org/D74351
More information about the libcxx-commits
mailing list