summaryrefslogtreecommitdiffstats
path: root/core/config.hh
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-06-28 01:59:49 +0500
committeruntodesu <kirill@untode.su>2025-06-28 01:59:49 +0500
commit61e5bcef2629e2d68b805a956a96fff264d4f74d (patch)
treebca3a94bac79d34e3c0db57c77604f5a823ecbda /core/config.hh
parent88c01588aa0830e219eaa62588839e4d1e2883ce (diff)
downloadvoxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.tar.bz2
voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.zip
Restructure dependencies and update to C++20
- Nuked static_assert from almost everywhere in the project - Nuked binary dependency support. Might add one later though - Separated dependency headers into a separate include subdirectory - Grafted a thirdpartylegalnotices.txt generator from RITEG - Pushed development snapshot version to 2126 (26th week of 2025)
Diffstat (limited to 'core/config.hh')
-rw-r--r--core/config.hh24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/config.hh b/core/config.hh
index 3df0870..efb2ef0 100644
--- a/core/config.hh
+++ b/core/config.hh
@@ -2,6 +2,8 @@
#define CORE_CONFIG_HH 1
#pragma once
+#include "core/concepts.hh"
+
class IConfigValue {
public:
virtual ~IConfigValue(void) = default;
@@ -29,10 +31,8 @@ public:
static bool from_string(const char* value);
};
-template<typename T>
+template<vx::Arithmetic T>
class ConfigNumber : public IConfigValue {
- static_assert(std::is_arithmetic_v<T>);
-
public:
explicit ConfigNumber(T default_value = T(0));
explicit ConfigNumber(T default_value, T min_value, T max_value);
@@ -112,7 +112,7 @@ private:
std::unordered_map<std::string, IConfigValue*> m_values;
};
-template<typename T>
+template<vx::Arithmetic T>
inline ConfigNumber<T>::ConfigNumber(T default_value)
{
m_value = default_value;
@@ -121,7 +121,7 @@ inline ConfigNumber<T>::ConfigNumber(T default_value)
m_string = std::to_string(default_value);
}
-template<typename T>
+template<vx::Arithmetic T>
inline ConfigNumber<T>::ConfigNumber(T default_value, T min_value, T max_value)
{
m_value = default_value;
@@ -130,7 +130,7 @@ inline ConfigNumber<T>::ConfigNumber(T default_value, T min_value, T max_value)
m_string = std::to_string(default_value);
}
-template<typename T>
+template<vx::Arithmetic T>
inline void ConfigNumber<T>::set(const char* value)
{
std::istringstream(value) >> m_value;
@@ -138,38 +138,38 @@ inline void ConfigNumber<T>::set(const char* value)
m_string = std::to_string(m_value);
}
-template<typename T>
+template<vx::Arithmetic T>
inline const char* ConfigNumber<T>::get(void) const
{
return m_string.c_str();
}
-template<typename T>
+template<vx::Arithmetic T>
inline T ConfigNumber<T>::get_value(void) const
{
return m_value;
}
-template<typename T>
+template<vx::Arithmetic T>
inline void ConfigNumber<T>::set_value(T value)
{
m_value = std::clamp(value, m_min_value, m_max_value);
m_string = std::to_string(m_value);
}
-template<typename T>
+template<vx::Arithmetic T>
inline T ConfigNumber<T>::get_min_value(void) const
{
return m_min_value;
}
-template<typename T>
+template<vx::Arithmetic T>
inline T ConfigNumber<T>::get_max_value(void) const
{
return m_max_value;
}
-template<typename T>
+template<vx::Arithmetic T>
inline void ConfigNumber<T>::set_limits(T min_value, T max_value)
{
m_min_value = min_value;