Skip to content

Commit

Permalink
inlines count_code_points(basic_string_view<char8_t)
Browse files Browse the repository at this point in the history
count_code_points(basic_string_view<char8_t>) was defined in
fmt/format-inl.h, and only declared in fmt/format.h, but not defined
in src/format.cc. This commit moves the overload to fmt/format.h and
inlines it.
  • Loading branch information
cjdb authored and vitaut committed Jun 1, 2019
1 parent f57227a commit c929684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 0 additions & 9 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,6 @@ void report_error(FormatFunc func, int error_code,
}
} // namespace

FMT_FUNC size_t internal::count_code_points(basic_string_view<char8_t> s) {
const char8_t* data = s.data();
size_t num_code_points = 0;
for (size_t i = 0, size = s.size(); i != size; ++i) {
if ((data[i] & 0xc0) != 0x80) ++num_code_points;
}
return num_code_points;
}

#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
namespace internal {

Expand Down
9 changes: 8 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,14 @@ inline size_t count_code_points(basic_string_view<Char> s) {
}

// Counts the number of code points in a UTF-8 string.
FMT_API size_t count_code_points(basic_string_view<char8_t> s);
inline size_t count_code_points(basic_string_view<char8_t> s) {
const char8_t* data = s.data();
size_t num_code_points = 0;
for (size_t i = 0, size = s.size(); i != size; ++i) {
if ((data[i] & 0xc0) != 0x80) ++num_code_points;
}
return num_code_points;
}

inline char8_t to_char8_t(char c) { return static_cast<char8_t>(c); }

Expand Down

0 comments on commit c929684

Please sign in to comment.