Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STL: Update __cpp_lib_concepts conditionals when all supported C++20 frontends support Concepts #395

Closed
2 of 3 tasks
CaseyCarter opened this issue Dec 18, 2019 · 1 comment · Fixed by #4298
Closed
2 of 3 tasks
Labels
enhancement Something can be improved fixed Something works now, yay!

Comments

@CaseyCarter
Copy link
Member

CaseyCarter commented Dec 18, 2019

Quite a bit of C++20-only code in the STL which uses C++20's Concepts feature is currently guarded with #ifdef __cpp_lib_concepts. __cpp_lib_concepts is defined in <yvals_core.h> only if __cpp_concepts is defined, so the result is that parts of the library that need concepts are only available if the compiler supports concepts.

Once our C++20-supported compilers (MSVC, IntelliSense (EDG), and Clang) all support concepts, each occurrence of #ifdef __cpp_lib_concepts can and should be replaced with #if _HAS_CXX20. Occurrences of #if _HAS_CXX20 resulting from this process that are nested within #if _HAS_CXX20 or #if _HAS_CXX23 can then be made unconditional.

  • MSVC (supports concepts as of VS 16.3)
  • Clang (Clang 10 supports concepts)
  • EDG/IntelliSense
@CaseyCarter CaseyCarter added enhancement Something can be improved blocked Something is preventing work on this labels Dec 18, 2019
@CaseyCarter CaseyCarter changed the title STL: Update __cpp_lib_concepts conditionals when supported C++20 frontends support concepts STL: Update __cpp_lib_concepts conditionals when all supported C++20 frontends support concepts Dec 18, 2019
@CaseyCarter CaseyCarter mentioned this issue Mar 3, 2020
4 tasks
@CaseyCarter
Copy link
Member Author

From #1648 (comment):

There are occurrences in <array> and <vector> where < <= > >= (marked as _CONSTEXPR20 and _CONSTEXPR20_CONTAINER) are guarded by !defined(__cpp_lib_concepts); those cannot be changed [by removing the _CONSTEXPR20_MEOW annotations, since those operators should not be active in C++20 mode] yet.

StephanTLavavej added a commit to StephanTLavavej/STL that referenced this issue Aug 4, 2022
@CaseyCarter CaseyCarter changed the title STL: Update __cpp_lib_concepts conditionals when all supported C++20 frontends support concepts STL: Update __cpp_lib_concepts conditionals when all supported C++20 frontends support Concepts Aug 4, 2022
CaseyCarter added a commit to CaseyCarter/STL that referenced this issue Aug 24, 2022
We should try to minimize the number of feature-test macros used to guard conditionally-compiled product code, so that readers aren't required to memorize the content of SD-6 in order to comprehend the STL. Consequently, feature-test macros should only be used in product code when their values are not implied by language mode or a conjunction of language mode and some other feature-test macro. We should instead test `_HAS_CXXYY && defined(__other_feature_macro)` directly. Feature-test macros whose values vary according to compiler flags other than language modes, or for features that aren't yet implemented by all compilers should be tested directly (although latter will eventually be replace by langage mode tests when the minimum required versions of all supported compilers implement the feature).

Some consequences of these rules:

* `_HAS_CXX20 && defined(__cpp_lib_concepts)` is redundant since `defined(__cpp_lib_concepts)` implies `_HAS_CXX20`.

* `_HAS_CXX20` implies `__cpp_constexpr_dynamic_alloc` now that all supported C++20 front ends implement that feature

* `defined(__cpp_lib_concepts)` implies `defined(__cpp_lib_format)`

* `_HAS_CXX23 && defined(__cpp_lib_concepts)` implies `defined(__cpp_expected)` and `defined(__cpp_lib_containers_ranges)`

[Note that we don't annotate plain `defined(__cpp_lib_concepts)` with `// TRANSITION, microsoftGH-395` in product because microsoftGH-395 clearly indicates that all such tests should be replaced and we don't want to churn just to add the annotation.]
CaseyCarter added a commit to CaseyCarter/STL that referenced this issue Aug 25, 2022
* remove redundant nested `_HAS_CXX23`s
* remove `// TRANSITION, microsoftGH-395` from `#ifn?def __cpp_lib_concepts` for consistency
* don't be lazy and use `// TRANSITION, microsoftGH-395` as an `#endif` comment instead of the actual test condition
cpplearner added a commit to cpplearner/STL that referenced this issue Jan 4, 2024
The following substitutions are performed:

- `#elif _HAS_CXX20 && defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#elif _HAS_CXX20`
- `#elif defined(__cpp_lib_concepts)` => `#elif _HAS_CXX20`
- `#else // ^^^ !defined(__cpp_lib_concepts) / defined(__cpp_lib_concepts) vvv` => `#else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv`
- `#else // ^^^ _HAS_CXX20 && !defined(__cpp_lib_concepts) / !_HAS_CXX20 vvv` => `#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv`
- `#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv` => `#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv`
- `#endif // !_HAS_CXX20 || !defined(__cpp_lib_concepts)` => `#endif // !_HAS_CXX20`
- `#endif // ^^^ !defined(__cpp_lib_concepts) ^^^` => `#endif // ^^^ !_HAS_CXX20 ^^^`
- `#endif // ^^^ defined(__cpp_lib_concepts) ^^^` => `#endif // ^^^ _HAS_CXX20 ^^^`
- `#endif // _HAS_CXX20 && defined(__cpp_lib_concepts)` => `#endif // _HAS_CXX20`
- `#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)` => `#endif // _HAS_CXX23`
- `#endif // _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#endif // _HAS_CXX23`
- `#endif // __cpp_lib_concepts` => `#endif // _HAS_CXX20`
- `#endif // defined(__cpp_lib_concepts)` => `#endif // _HAS_CXX20`
- `#endif // defined(__cpp_lib_concepts) && _HAS_CXX23` => `#endif // _HAS_CXX23`
- `#if !_HAS_CXX20 || !defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#if !_HAS_CXX20`
- `#if !_HAS_CXX23 || !defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#if !_HAS_CXX23`
- `#if _HAS_CXX20 && defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#if _HAS_CXX20`
- `#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#if _HAS_CXX23`
- `#if _HAS_CXX23 && defined(__cpp_lib_concepts)` => `#if _HAS_CXX23`
- `#if defined(__cpp_lib_concepts) && _HAS_CXX23` => `#if _HAS_CXX23`
- `#if defined(__cpp_lib_concepts) // TRANSITION, microsoftGH-395` => `#if _HAS_CXX20`
- `#if defined(__cpp_lib_concepts)` => `#if _HAS_CXX20`
- `#ifdef __cpp_lib_concepts // TRANSITION, microsoftGH-395` => `#if _HAS_CXX20`
- `#ifdef __cpp_lib_concepts` => `#if _HAS_CXX20`
- `#ifndef __cpp_lib_concepts` => `#if !_HAS_CXX20`
cpplearner added a commit to cpplearner/STL that referenced this issue Jan 4, 2024
cpplearner added a commit to cpplearner/STL that referenced this issue Jan 9, 2024
@StephanTLavavej StephanTLavavej added fixed Something works now, yay! and removed blocked Something is preventing work on this labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants