-
Notifications
You must be signed in to change notification settings - Fork 16
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
Set minimum required C++ version to C++17 #38
Conversation
This is required for the nested namespace specifiers in identity.hpp
beman.exemplar's build instructions suggest using The reason we aren't using I'm beginning to think we need a try_compile call that'll give the user a good error message if the compiler isn't sufficient (e.g. suggesting using -DCMAKE_CXX_STANDARD). |
This comment was marked as resolved.
This comment was marked as resolved.
Yes, that will solve it.
I don't quite follow the rationale here. You have a de-facto |
Because letting packages change the ABI of the consumer breaks package management. The model Cmake uses only works, to the extent that it does, if every package is built as part of the same project, and even then it produces surprises. Packages must build with the ABI they are given, and fail if they can't be built using those flags. Failure is an option in package management. But also changes like adding members to std::string have had ABI changes in real implementations, such as RH's developer toolset, because it means the full template instantiation can't be used from the existing system libraries, and instead must be emitted, which means that symbol resolution changes cause link changes. |
We're also a bit torn here between extra complications that a simple example doesn't need, and a full project does. Optional26 specifies this, and other flags, as part of the toolchain file used for the build. That's the mechanism that package management systems often use to provide build instructions, if they don't replace the package build system wholesale. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to require a minimum version, it should be C++20 due to this example https://github.com/beman-project/exemplar/blob/main/examples/CMakeLists.txt#L4. I'll re-enable it - TLDR exemplar requires range support (https://en.cppreference.com/w/cpp/algorithm/ranges). Apologies for this inconvenience and thanks @ComicSansMS for contributing!
Just created #41
If we do that, I'm afraid we'll cut off several developers who are still on 17. Should we selectively enable the test based on a |
Given the mission of the project I'd say that 20 is a bare minimum for working on anything in Beman. In particular the implementation techniques are radically different for standards proposals pre-20 and post. Requires clauses make a huge difference in rendering a library. |
============================================= The production code and tests (everything that is in ============================================= I also think setting C++20 is a normal constraint for Beman repos. However, I'm not opposing to discuss further this approach vs
Possibilities here:
|
I am for setting |
It's a tradeoff. One of the goals of the Beman project is to collect user feedback on proposed standard libraries before they land in the standard. Requiring newer compilers will block several folks, especially those in large companies, from getting that feedback. At Adobe, for example, not all our compilers support C++20 yet. That being said, if there's a huge implementation burden to supporting older compilers for a particular library then it makes sense to require something newer. I'd take it on a case-by-case basis. |
Expressing Constraints clauses is the big one. Anything other than a constraint-expression is an implementation burden. https://timsong-cpp.github.io/cppwp/n4861/structure#specifications-3.1 Constexpr if is also the natural way of expressing some of the requirements in the library descriptions. There are other ways of doing things, but often not easily or well. It's of course case-by-case, but don't be surprised if almost all are C++20 minimum. Compare libc++ optional with Optional26. |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously requested change completed in #55 .
We had consensus on exemplar supporting C++ 17 during today's weekly meeting thus this pr should move forward.
My understanding is that the original motivation for this PR is that the build would fail when you don't set your compilation flags appropriately with something like Adding If I understand correctly, this PR can now be closed with merging since the original concern is addressed. @ComicSansMS, did I get this right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, if we still want to add the config in that file. C++17 is accepted right now.
Closing because presets already address this concern and don't have the drawback of changing dependent compiler flags. @ComicSansMS or others please feel free to reopen if you disagree. |
This is required for the nested namespace specifiers in identity.hpp.
Without this change, the example will fail to compile on MSVC.
If it is not desirable to have a C++17 as the minimum version, the example code should be changed to not rely on any C++17 features instead.