Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryAWE committed Jan 31, 2024
1 parent e43b43a commit 8912697
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions include/papilio/utf/codepoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,11 @@ class codepoint_iterator : public detail::cp_iter_impl<CharT>
lhs.swap(rhs);
}

template <typename CharT>
friend codepoint_iterator<CharT> codepoint_begin(std::basic_string_view<CharT> str) noexcept;
template <typename CharU>
friend codepoint_iterator<CharU> codepoint_begin(std::basic_string_view<CharU> str) noexcept;

template <typename CharT>
friend codepoint_iterator<CharT> codepoint_end(std::basic_string_view<CharT> str) noexcept;
template <typename CharU>
friend codepoint_iterator<CharU> codepoint_end(std::basic_string_view<CharU> str) noexcept;
};
} // namespace papilio::utf

Expand Down
20 changes: 10 additions & 10 deletions include/papilio/utf/codepoint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,26 @@ constexpr auto decoder<char16_t>::from_codepoint(codepoint cp) -> from_codepoint
return result;
}

template <typename CharT>
codepoint_iterator<CharT> codepoint_begin(std::basic_string_view<CharT> str) noexcept
template <typename CharU>
codepoint_iterator<CharU> codepoint_begin(std::basic_string_view<CharU> str) noexcept
{
using result_t = codepoint_iterator<CharT>;
using result_t = codepoint_iterator<CharU>;

if constexpr(!char32_like<CharT>) // char8_like and char16_like
if constexpr(!char32_like<CharU>) // char8_like and char16_like
{
if(str.empty())
return result_t(str, 0, std::uint8_t(0));
}

if constexpr(char8_like<CharT>)
if constexpr(char8_like<CharU>)
{
std::uint8_t ch = str[0];
std::uint8_t ch_size = PAPILIO_NS utf::is_leading_byte(ch) ?
PAPILIO_NS utf::byte_count(ch) :
1;
return result_t(str, 0, ch_size);
}
else if constexpr(char16_like<CharT>)
else if constexpr(char16_like<CharU>)
{
std::uint16_t ch = str[0];
std::uint8_t ch_size = PAPILIO_NS utf::is_high_surrogate(ch) ?
Expand All @@ -216,12 +216,12 @@ codepoint_iterator<CharT> codepoint_begin(std::basic_string_view<CharT> str) noe
}
}

template <typename CharT>
codepoint_iterator<CharT> codepoint_end(std::basic_string_view<CharT> str) noexcept
template <typename CharU>
codepoint_iterator<CharU> codepoint_end(std::basic_string_view<CharU> str) noexcept
{
using result_t = codepoint_iterator<CharT>;
using result_t = codepoint_iterator<CharU>;

if constexpr(!char32_like<CharT>) // char8_like and char16_like
if constexpr(!char32_like<CharU>) // char8_like and char16_like
{
return result_t(str, str.size(), std::uint8_t(0));
}
Expand Down

0 comments on commit 8912697

Please sign in to comment.