diff --git a/icu4c/source/common/unicode/char16ptr.h b/icu4c/source/common/unicode/char16ptr.h index 049de9efee81..4715c93435bf 100644 --- a/icu4c/source/common/unicode/char16ptr.h +++ b/icu4c/source/common/unicode/char16ptr.h @@ -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 >> +std::u16string_view toU16StringView(const T& text) { return text; } #if !U_CHAR16_IS_TYPEDEF && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 180000) /** @@ -427,7 +429,7 @@ inline std::u16string_view toU16StringView(std::wstring_view sv) { */ template >>> -inline std::u16string_view toU16StringViewNullable(const T& text) { +std::u16string_view toU16StringViewNullable(const T& text) { return toU16StringView(text); } @@ -438,7 +440,7 @@ inline std::u16string_view toU16StringViewNullable(const T& text) { template >>, 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); }