diff options
author | rtk0c <[email protected]> | 2021-05-31 12:27:58 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-05-31 12:27:58 -0700 |
commit | 8157678eba97d7de5c53b424a9866d327392bbd9 (patch) | |
tree | 26348a926040ccfc91f74cdfe49f7153db271f87 /core/src/Model/Workflow/Values | |
parent | eef2514908cdec3ec02888b7467cc877d33c1ceb (diff) |
Fix standard incompetence found by MSVC
- requires-expression still not working, because they aren't supported yet outside of a concept
Diffstat (limited to 'core/src/Model/Workflow/Values')
-rw-r--r-- | core/src/Model/Workflow/Values/BasicValues.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/core/src/Model/Workflow/Values/BasicValues.cpp b/core/src/Model/Workflow/Values/BasicValues.cpp index a7cf635..748c652 100644 --- a/core/src/Model/Workflow/Values/BasicValues.cpp +++ b/core/src/Model/Workflow/Values/BasicValues.cpp @@ -14,14 +14,13 @@ NumericValue::NumericValue() { } -template <class T> +template <class T, int kMaxSize> static std::string NumberToString(T value) { - constexpr auto kSize = std::numeric_limits<T>::max_digits10; - char buf[kSize]; + char buf[kMaxSize]; #if PLATFORM_WIN32 - auto res = std::to_chars(buf, buf + kSize, value); + auto res = std::to_chars(buf, buf + kMaxSize, value); if (res.ec == std::errc()) { return std::string(buf, res.ptr); } else { @@ -35,17 +34,20 @@ static std::string NumberToString(T value) std::string NumericValue::GetTruncatedString() const { - return ::NumberToString((int64_t)mValue); + constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10; + return ::NumberToString<int64_t, kMaxSize>((int64_t)mValue); } std::string NumericValue::GetRoundedString() const { - return ::NumberToString((int64_t)std::round(mValue)); + constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10; + return ::NumberToString<int64_t, kMaxSize>((int64_t)std::round(mValue)); } std::string NumericValue::GetString() const { - return ::NumberToString(mValue); + constexpr auto kMaxSize = std::numeric_limits<double>::max_digits10; + return ::NumberToString<double, kMaxSize>(mValue); } int64_t NumericValue::GetInt() const |