Replace uses of SFINAE with concept/requires based equivalents [NFC]#204
Merged
Merged
Conversation
930305f to
75b0e43
Compare
The CMake config has C++20 as part of the public interface, but that only protects against normal, by-the-book CMake machinery. Setting compilation flags manually bypasses those checks. So, also add a header guard to completely prevent compilation using previous standards. MSVC forces the header guard check to be more complex than it should be: MSVC only correctly sets the `__cplusplus` value if an additional (non-default) compile option `/Zc:__cplusplus` is set; `_MSVC_LANG` always contains the standard value.
The concept definition combines the previous SFINAE checks that `detail::has_call_operator<LambdaT>::value && !std::is_member_function_pointer_v<LambdaT>`
75b0e43 to
11b815c
Compare
Contributor
|
Thanks, this seems much simpler. Any idea what version of GCC would be required for this to compile? |
Contributor
Author
|
Looking at the GCC C++ standards page, GCC 10 is when support for concepts landed. |
This allows GCC 10.2 to compile the code.
Contributor
|
I tested with GCC 10.2 with BinaryBuilder (what is currently used by the Yggdrasil build script) and I needed to lower the minimum version in the check. This allows us to continue to use the same GCC version, which means that once this is merged it can be distributed as a minor version update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Aside from the first commit1, each commit replaces independent instances of the SFINAE
pattern with named concepts and/or
requiresstatements. I find that concepts/requiresare much more directly readable and easier to reason about, but I completely understand if
the code churn isn't worth it.
Footnotes
29c435c removes a remnant C++17 flag which is no longer correct, as libcxxwrap is
documented as having a minimum standard of C++20. (Setting the compilation flag manually
bypasses the CMake functionality that should've prevented this.) I strengthened min
standard requirement by adding a check in the headers. That check also protects
non-CMake consumers of libcxxwrap, because the C++20 requirement in the CMake config is
imposed within CMake, and not at a header/shared library level. ↩