Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions icu4c/source/common/unicode/char16ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ constexpr bool ConvertibleToU16StringView =

namespace internal {
/**
* Pass-through overload.
* Pass-through overload for anything which is already implicitly convertible (including std::u16string_view itself).
* @internal
*/
inline std::u16string_view toU16StringView(std::u16string_view sv) { return sv; }
template <typename T,
typename = typename std::enable_if_t<std::is_convertible_v<T, std::u16string_view>>>
std::u16string_view toU16StringView(const T& text) { return text; }

#if !U_CHAR16_IS_TYPEDEF && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 180000)
/**
Expand Down Expand Up @@ -427,7 +429,7 @@ inline std::u16string_view toU16StringView(std::wstring_view sv) {
*/
template <typename T,
typename = typename std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>>>
inline std::u16string_view toU16StringViewNullable(const T& text) {
std::u16string_view toU16StringViewNullable(const T& text) {
return toU16StringView(text);
}

Expand All @@ -438,7 +440,7 @@ inline std::u16string_view toU16StringViewNullable(const T& text) {
template <typename T,
typename = typename std::enable_if_t<std::is_pointer_v<std::remove_reference_t<T>>>,
typename = void>
inline std::u16string_view toU16StringViewNullable(const T& text) {
std::u16string_view toU16StringViewNullable(const T& text) {
if (text == nullptr) return {}; // For backward compatibility.
return toU16StringView(text);
}
Expand Down