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

[Core] TraitsData::getTraitProperty should not be [[nodiscard]] #825

Closed
feltech opened this issue Mar 1, 2023 · 0 comments · Fixed by #828
Closed

[Core] TraitsData::getTraitProperty should not be [[nodiscard]] #825

feltech opened this issue Mar 1, 2023 · 0 comments · Fixed by #828
Assignees
Labels

Comments

@feltech
Copy link
Member

feltech commented Mar 1, 2023

What

Remove [[nodiscard]] attribute from TraitsData::getTraitProperty, or otherwise redesign getTraitProperty.

Why

The design of getTraitProperty uses an out-parameter for the value the user is most interested in. The return value is a bool indicating whether the property is set. A possible valid use case is ignoring the return value, e.g. in a "value or default" flow:

openassetio::Str value = "fallback";
traitsData->getTraitProperty(&value, traitId, key);

where value will be the stored value if set, or will remain "fallback" if not. In this case, the returned bool is not interesting and can be safely ignored.

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

Successfully merging a pull request may close this issue.

2 participants