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

[Enhancement]: introduce conditional noexcept #2197

Open
kamilsa opened this issue Aug 28, 2024 · 0 comments
Open

[Enhancement]: introduce conditional noexcept #2197

kamilsa opened this issue Aug 28, 2024 · 0 comments

Comments

@kamilsa
Copy link
Contributor

kamilsa commented Aug 28, 2024

Description

After internal discussion in the team it was decided that we need to conditional noexcept instead of original noexcept function. Conditional noexcept could be defined in a form:

#ifdef ENABLE_NOEXCEPT // Assuming you have defined this flag during compilation
#define CONDITIONAL_NOEXCEPT noexcept
#else
#define CONDITIONAL_NOEXCEPT 
#endif

// Usage
void myFunction() CONDITIONAL_NOEXCEPT {
    // ... function implementation
}

Motivation

Motivation is to take advantage of using noexcept:

  1. Compiler's optimization of noexcept functions
  2. Clarity of developers intent when it is observed that function is defined as noexcept

At the same time noexcept can bring some additional challenges such as runtime termination: if exception is thrown inside noexcept function, stack trace of the crash might be incomplete.

Therefore it makes sense to put noexcept under conditional #define defined during compilation time

Additional context

It makes sense to introduce such define in qtils repo, to take advantage of such define in any project (KAGOME, libp2p, etc)

Are you planning to do it yourself in a pull request ?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant