This implements the new type trait common_ref that is needed for library concepts support
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 46193 Build 48507: arc lint + arc unit
Event Timeline
libcxx/include/type_traits | ||
---|---|---|
2306–2307 | Perhaps we should hold off on merging this so we can use std::convertible_to instead. |
@cjdb I have to disagree. That would create a ciruclar dependency between concepts and type_traits, which is in my opinion not worth it.
Also note that std::convertible_to essentially falls back to is_convertible_v
libcxx/include/type_traits | ||
---|---|---|
2292–2318 | I think I should add the respective wording here so that one understands what it is actually testing. |
libcxx/include/type_traits | ||
---|---|---|
2306–2307 | I would add that std::convertible_to has slightly different semantics too as it has some addtional requires clauses |
libcxx/include/type_traits | ||
---|---|---|
2306–2307 | 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. |
libcxx/include/type_traits | ||
---|---|---|
2306–2307 | 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? |
libcxx/include/type_traits | ||
---|---|---|
2306–2307 | Since common_reference is really only useful with ranges in mind, we could section this code off with feature-test macros? |
@miscco What is the status of this commit? I will review it on Wednesday if it's still in good shape.
Ping
Hey,
as far as I can tell it should be still up to date. I have only limited time right now to look at it in depth though
libcxx/include/type_traits | ||
---|---|---|
2306–2307 |
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. |
@miscco I took this patch and reworked it slightly in D96657 so that it's a bit closer to the standard wording (it's a separate patch because I didn't want to overwrite your implementation with such a drastic change).
Are you okay with this, or have I overlooked an advantage to you moving some of COMMON-REF into common_reference?
@cjdb I am totally fine with dropping this revision. Thanks a lot for working on this!
Perhaps we should hold off on merging this so we can use std::convertible_to instead.