Skip to content

Commit

Permalink
Include needed headers for concepts and std::errc
Browse files Browse the repository at this point in the history
Merge request feedback pointed out missing headers, so I added them. Also
changed to using the std::same_as concept instead of the type_traits version
since we are already using concepts anyways.
  • Loading branch information
CrustyAuklet committed Apr 27, 2024
1 parent 068a72b commit a5cf5aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/snitch_append.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "snitch/snitch_append.hpp"
#include "snitch/snitch_string.hpp"

#include <charconv> // for std::to_chars
#include <cstring> // for std::memmove
#include <concepts> // for std::floating_point, std::same_as
#include <system_error> // for std::errc


namespace snitch::impl {
namespace {
Expand All @@ -17,7 +21,7 @@ using snitch::small_string_span;
template<std::floating_point T>
bool append_to_chars(small_string_span ss, T value) noexcept {
constexpr auto fmt = std::chars_format::scientific;
constexpr auto precision = std::is_same_v<float, T> ? 6 : 15;
constexpr auto precision = std::same_as<float, T> ? 6 : 15;
auto [end, err] = std::to_chars(ss.end(), ss.begin() + ss.capacity(), value, fmt, precision);
if (err != std::errc{}) {
// Not enough space, try into a temporary string that *should* be big enough,
Expand Down

0 comments on commit a5cf5aa

Please sign in to comment.