Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)

This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
This commit is contained in:
Peter Nelson
2023-11-06 20:29:35 +00:00
committed by GitHub
parent 737775f834
commit ab535c0a86
73 changed files with 174 additions and 173 deletions

View File

@@ -174,25 +174,25 @@ struct IntSettingDesc : SettingDesc {
str(str), str_help(str_help), str_val(str_val), cat(cat), pre_check(pre_check),
post_callback(post_callback) {
if constexpr (std::is_base_of_v<StrongTypedefBase, Tdef>) {
this->def = static_cast<typename Tdef::BaseType>(def);
this->def = def.base();
} else {
this->def = def;
}
if constexpr (std::is_base_of_v<StrongTypedefBase, Tmin>) {
this->min = static_cast<typename Tmin::BaseType>(min);
this->min = min.base();
} else {
this->min = min;
}
if constexpr (std::is_base_of_v<StrongTypedefBase, Tmax>) {
this->max = static_cast<typename Tmax::BaseType>(max);
this->max = max.base();
} else {
this->max = max;
}
if constexpr (std::is_base_of_v<StrongTypedefBase, Tinterval>) {
this->interval = static_cast<typename Tinterval::BaseType>(interval);
this->interval = interval.base();
} else {
this->interval = interval;
}