-
Notifications
You must be signed in to change notification settings - Fork 160
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
[onert] Apply c++17 features #14647
Comments
if constexpr |
Template Argument Deduction for Class Templates (Deduction Guides)This feature could negatively impact readability, so I will not be applying it. |
Filesystem Library (std::filesystem)This feature was already resolved by #12450 |
std::optionalConsidering consistency with the existing code and potential performance overhead, I did not find any suitable places to apply |
Parallel Algorithms (Execution Policies)According to https://en.cppreference.com/w/cpp/compiler_support/17, neither GCC nor Clang fully support this feature. Also, according to https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017:
This means that when using parallel algorithms in C++17, the feature relies on Intel TBB 2018 (or later), and you must link with TBB (using the -ltbb flag) if you include the header. |
[[nodiscard]] Attribute |
Type Trait Enhancements |
I am not sure all items of the listed c++17 pays or valuable.
For example, using We may choose the most effective items selectively. |
Not every C++17 feature is a silver bullet for every project. The bullet points are general benefits that may apply in many cases, but the actual impact depends on your codebase and use case. For instance:
In summary, we don't have to adopt every C++17 feature blindly. We can evaluate each one based on its impact on our project's simplicity, maintainability, performance, safety, and consistency—and choose the most effective ones selectively. |
I'm closing this issue as I think I have applied a sufficient number of C++ features, even though I didn't aim to cover all of them. |
What
Let's apply C++17 features to onert. The goal is to modernize the codebase by leveraging new language features, thereby simplifying the code and improving maintainability.
Why
Features to be applied
Nested Namespace Declarations
Inline Variables
Structured Bindings
if constexpr
Fold Expressions
Template Argument Deduction for Class Templates (Deduction Guides)
Filesystem Library (std::filesystem)
std::optional
std::variant
std::any
std::string_view
Parallel Algorithms (Execution Policies)
[[nodiscard]] Attribute
std::void_t
std::uncaught_exceptions()
std::shared_mutex
particularly useful in multithreaded code where you have many concurrent read operations.
std::not_fn
std::byte
Type Trait Enhancements
The text was updated successfully, but these errors were encountered: