Skip to content

Commit

Permalink
fix build with mingw not supporting std::to_char with floats
Browse files Browse the repository at this point in the history
  • Loading branch information
amurzeau committed Sep 14, 2024
1 parent cc5b519 commit 30b1e69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions damc_common/Osc/OscNode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <functional>
#include <stdint.h>
#include <string>
#include <type_traits>
#include <variant>
Expand Down
13 changes: 5 additions & 8 deletions damc_gui/OscWidgetMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "QtUtils.h" // IWYU pragma: keep: needed for qOverload on older Qt versions (< 5.7)
#include <charconv>
#include <spdlog/spdlog.h>
#include <sstream>
#include <stdexcept>
#include <type_traits>

Expand Down Expand Up @@ -155,14 +156,10 @@ template<class T, class UnderlyingType> std::string OscWidgetMapper<T, Underlyin
} else if constexpr(std::is_same_v<UnderlyingType, bool>) {
return value ? "true" : "false";
} else {
std::string result;
result.resize(128);
auto [ptr, ec] = std::to_chars(result.data(), result.data() + result.size(), this->value);
if(ec != std::errc{}) {
throw std::runtime_error(fmt::format("failed to convert value {} to string", value));
}
result.resize(ptr - result.data());
return result;
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << this->value;
return oss.str();
}
}

Expand Down

0 comments on commit 30b1e69

Please sign in to comment.