-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add ConfigObject::get-/setValue<EnumType>
#11883
Conversation
src/preferences/configobject.h
Outdated
template <class ResultType> | ||
ResultType getValue(const ConfigKey& key, const ResultType& default_value) const; | ||
QString getValue(const ConfigKey& key, const char* default_value) const; | ||
template<typename EnumType> | ||
requires std::is_enum_v<EnumType> |
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.
template <class ResultType> | |
ResultType getValue(const ConfigKey& key, const ResultType& default_value) const; | |
QString getValue(const ConfigKey& key, const char* default_value) const; | |
template<typename EnumType> | |
requires std::is_enum_v<EnumType> | |
template <class ResultType, std::enable_if_t<!std::is_enum_v<ResultType>, bool> = true> | |
ResultType getValue(const ConfigKey& key, const ResultType& default_value) const; | |
QString getValue(const ConfigKey& key, const char* default_value) const; | |
template<typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>, bool> = true> |
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.
explicitly opting out of enums for the default template is unnecessary when using requires
as the template with requires
has a higher specificity and is thus chosen over the unconstrained template. I'd prefer to not have the negative requirement, as the maintenance burden will explode in case we add even more templates.
src/preferences/configobject.h
Outdated
template <class ResultType> | ||
void setValue(const ConfigKey& key, const ResultType& value); | ||
template<class EnumType> | ||
requires std::is_enum_v<EnumType> |
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.
We need to use std::enable_if
if you want to merge this into 2.4 because requires does not work with Ubuntu Focal
The alternative would be to merge that to main, because this is not a last minute bug fix.
But I consider that a low risk PR that we can let slip in.
template <class ResultType> | |
void setValue(const ConfigKey& key, const ResultType& value); | |
template<class EnumType> | |
requires std::is_enum_v<EnumType> | |
template <class ResultType, std::enable_if_t<!std::is_enum_v<ResultType>, bool> = true> | |
void setValue(const ConfigKey& key, const ResultType& value); | |
template<class EnumType, std::enable_if_t<std::is_enum_v<EnumType>, bool> = true> |
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.
The alternative would be to merge that to main, because this is not a last minute bug fix.
I'd prefer merging to main then. The error messages generated when using enable_if
are much uglier than the ones generated by requires
clauses.
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.
OK
I'll push a couple fixups. If you're okay with them I'll squash them and rebase onto |
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, Ready to rebase.
3c716dd
to
213e08c
Compare
213e08c
to
a587631
Compare
rebased to main, fixups are gone and it builds. merge? |
.pre-commit-config.yaml
Outdated
@@ -91,7 +91,7 @@ repos: | |||
- manual | |||
language: python | |||
additional_dependencies: | |||
- clang-format==14.0.6 | |||
- clang-format==16.0.6 |
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.
Isn't this from the pre-commit PR? Did you pull 2.4
into main
?
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.
No it was required to resolve the messed formatting I posted about above. I didn't pull 2.4 into main
because thats currently broken IIUC. I just figured I'd just update it here and the merge conflict will be easy to resolve later. The Alternative would be to cherry-pick #11889 into main
.
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.
Hmm, my local test worked fine, but if we changed deps this does look weird. Since #11839 has already been merged I'd rather take care of updating the vcpkg env now rather than risking that changes in 2.4 pile up and become a pain to resolve later on.
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.
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.
I agree, I just don't like messing with the buildenv as that's not my area of expertise. Thank you for taking care.
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.
OK, we see now everything is green. So I suggest to remove the .pre-commit-config.yaml and we can merge this with the failing pre-commit (if #11892 does not make it before). This will avoid later conflicts and doe snot block this PR.
a587631
to
5d63b5c
Compare
removed the pre-commit change. CI is obviously still failing due it being broken on |
This allows the callsites to avoid verbose `static_cast`s. It also makes it easier to change the machanism used when storing enums in the config easier in the future.
5d63b5c
to
25462c7
Compare
merge? |
Yes, thank you. |
Thank you |
This allows the callsites to avoid verbose
static_cast
s (see 491b436). It also makes it easier to change the machanism used when storing enums in the config easier in the future. The remaining commits are cleanups I did along the way while making use of the new overload.