aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Values/BasicValues.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Model/Workflow/Values/BasicValues.cpp')
-rw-r--r--core/src/Model/Workflow/Values/BasicValues.cpp16
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