Skip to content

Commit

Permalink
Move digits10 to where they belong and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jun 4, 2020
1 parent 0f3eaea commit 88c8d53
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,12 @@ inline int count_digits(uint32_t n) {
}
#endif

template <typename Int> constexpr int digits10() FMT_NOEXCEPT {
return std::numeric_limits<Int>::digits10;
}
template <> constexpr int digits10<int128_t>() FMT_NOEXCEPT { return 38; }
template <> constexpr int digits10<uint128_t>() FMT_NOEXCEPT { return 38; }

template <typename Char> FMT_API std::string grouping_impl(locale_ref loc);
template <typename Char> inline std::string grouping(locale_ref loc) {
return grouping_impl<char>(loc);
Expand All @@ -857,13 +863,15 @@ template <> inline wchar_t decimal_point(locale_ref loc) {
return decimal_point_impl<wchar_t>(loc);
}

// Compares two characters for equality.
template <typename Char> bool equal2(const Char* lhs, const char* rhs) {
return lhs[0] == rhs[0] && lhs[1] == rhs[1];
}
inline bool equal2(const char* lhs, const char* rhs) {
return memcmp(lhs, rhs, 2) == 0;
}

// Copies two characters from src to dst.
template <typename Char> void copy2(Char* dst, const char* src) {
*dst++ = static_cast<Char>(*src++);
*dst = static_cast<Char>(*src);
Expand Down Expand Up @@ -892,12 +900,6 @@ inline Char* format_decimal(Char* out, UInt value, int num_digits) {
return end;
}

template <typename Int> constexpr int digits10() FMT_NOEXCEPT {
return std::numeric_limits<Int>::digits10;
}
template <> constexpr int digits10<int128_t>() FMT_NOEXCEPT { return 38; }
template <> constexpr int digits10<uint128_t>() FMT_NOEXCEPT { return 38; }

template <typename Char, typename UInt, typename Iterator,
FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<Iterator>>::value)>
inline Iterator format_decimal(Iterator out, UInt value, int num_digits) {
Expand Down

0 comments on commit 88c8d53

Please sign in to comment.