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

Let Profiling::ProfilingSection(std::string) constructor be explicit and nodiscard #6690

Merged
merged 2 commits into from Jan 3, 2024

Conversation

dalg24
Copy link
Member

@dalg24 dalg24 commented Jan 2, 2024

Rational: mostly consistency

This aligns with what we did for ScopedRegion

class [[nodiscard]] ScopedRegion {
public:
ScopedRegion(ScopedRegion const &) = delete;
ScopedRegion &operator=(ScopedRegion const &) = delete;
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard) >= 201907
[[nodiscard]]
#endif

The nodiscard attribute will warn on a common beginner error to "forget" to give the scope guard variable a name (although admittedly creating a section without calling start/stop is unlikely so that error would not occur in practice).

If we do any change at all, we might as well mark the constructor as explicit.

@crtrott
Copy link
Member

crtrott commented Jan 3, 2024

Retest this please.

@dalg24
Copy link
Member Author

dalg24 commented Jan 3, 2024

Ignoring Jenkins CI

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

Successfully merging this pull request may close these issues.

None yet

3 participants