Turn Config::Info into a class with getters

This commit is contained in:
JosJuice
2020-09-20 13:58:17 +02:00
parent 11e8783893
commit b285991b88
12 changed files with 62 additions and 53 deletions

View File

@ -30,10 +30,11 @@ struct Location
};
template <typename T>
struct Info
class Info
{
Info(const Location& location_, const T& default_value_)
: location{location_}, default_value{default_value_}
public:
constexpr Info(const Location& location, const T& default_value)
: m_location{location}, m_default_value{default_value}
{
}
@ -41,13 +42,17 @@ struct Info
// so that enum settings can still easily work with code that doesn't care about the enum values.
template <typename Enum,
std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr>
Info(const Info<Enum>& other)
: location{other.location}, default_value{static_cast<detail::UnderlyingType<Enum>>(
other.default_value)}
constexpr Info(const Info<Enum>& other)
: m_location{other.GetLocation()}, m_default_value{static_cast<detail::UnderlyingType<Enum>>(
other.GetDefaultValue())}
{
}
Location location;
T default_value;
constexpr const Location& GetLocation() const { return m_location; }
constexpr const T& GetDefaultValue() const { return m_default_value; }
private:
Location m_location;
T m_default_value;
};
} // namespace Config