Avoid concepts when __cpp_lib_concepts isn't defined #1749
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes DevCom-1367531 / VSO-1292416 "Intel C++ Compiler, ICL, has compilation failure because use of concepts in header file not guarded with
ifdef __cpp_lib_concepts
".Earlier related discussion: #919 (comment)
Our current policies are:
_HAS_CXX20 && !defined(__cpp_lib_concepts)
. Some machinery is unavailable in this mode (e.g.<ranges>
, some spaceship operators).<ranges>
.)Although EDG IntelliSense didn't have trouble with the
concept _Allocator
introduced by #919, the fact that it's causing a headache for the Intel C++ Compiler, it's easily avoided by using SFINAE, and using SFINAE is more consistent with our conventions, leads me to believe that we should make this change.I checked (by preprocessing
__msvc_all_public_headers.hpp
with/BE
) and the only other occurrence of aconcept
in_HAS_CXX20 && !defined(__cpp_lib_concepts)
mode was theis_clock
implementation added by #323. To be consistent, I'm converting that one to SFINAE too (and marking it as// TRANSITION, GH-602
as a reminder to switch back). Fortunately,void_t
makes it easy to query for the validity of multiple things simultaneously. As this is targeted, it shouldn't interfere withfeature/chrono
merging.Note that this "C++20 without concepts" mode is not permanent (maintaining it adds additional complexity to the codebase). After the EDG IntelliSense bugs are fixed, we'll begin using concepts unconditionally in C++20 mode (see #395), and converting SFINAE to concepts in C++20-only code when that makes sense (see #602).