Skip to content

Commit ef7739f

Browse files
committed
[#17]:svarga:feature, fix formatting
1 parent 3253fb4 commit ef7739f

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

include/decimal.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <cstdint>
1111
#include <limits>
1212
#include <string_view>
13+
#include <type_traits>
1314
#include <array>
14-
1515
#include <bid_conf.h>
1616
#include <bid_functions.h>
1717
#include <dfp754.h>
@@ -382,21 +382,21 @@ namespace math {
382382
#undef sigma_stream_op
383383

384384
namespace std {
385-
template <class T>
386-
struct formatter<math::decimal_t<T>> {
387-
template<typename ctx_t>
388-
constexpr auto parse(ctx_t& ctx) const {
389-
return ctx.begin();
385+
template <typename integral_t>
386+
struct formatter<math::decimal_t<integral_t>, char> {
387+
formatter<std::string_view, char> delegate;
388+
389+
constexpr auto parse(std::format_parse_context& ctx) {
390+
return delegate.parse(ctx);
390391
}
391392

392-
template <typename ctx_t>
393-
auto format(const math::decimal_t<T>& dec, ctx_t& ctx) const {
394-
return std::format_to(ctx.out(), "{}", static_cast<std::string>(dec));
393+
template <typename format_context_t>
394+
auto format(const math::decimal_t<integral_t>& value, format_context_t& ctx) const {
395+
const std::string text = static_cast<std::string>(value);
396+
return delegate.format(std::string_view{text}, ctx);
395397
}
396398
};
397-
} // namespace std
398-
399-
399+
}
400400
namespace math {
401401
/*
402402
intel_bid_prefixes := {__bid32_ __bid64_ __bid128_}

0 commit comments

Comments
 (0)