UnicodeString std::u16string_view APIs preferred by clang

8 views
Skip to first unread message

LN Liberda

unread,
Oct 12, 2025, 7:35:03 AMOct 12
to icu-s...@unicode.org
Hi,

Since std::u16string_view APIs were added to UnicodeString (ICU-22843),
they seem to be preferred by clang over the earlier APIs. For example,
operator= now uses the other UnicodeString via std::u16string_view,
rather than use the earlier assignment operator.

Is this a bug? If not, could these APIs get an opt-out through a define?

--
LN Liberda
it/its, het/dat, to [coś]/tego [czegoś]
https://liberda.nl/

Fredrik Roubert

unread,
Oct 13, 2025, 10:10:26 AMOct 13
to LN Liberda, icu-s...@unicode.org
On Sun, Oct 12, 2025 at 1:35 PM 'LN Liberda' via icu-support
<icu-s...@unicode.org> wrote:

> Since std::u16string_view APIs were added to UnicodeString (ICU-22843),
> they seem to be preferred by clang over the earlier APIs. For example,
> operator= now uses the other UnicodeString via std::u16string_view,
> rather than use the earlier assignment operator.

I'm unsure which operator= you're referring to as "the earlier
assignment operator". UnicodeString currently has the following
assignment operators:

operator=(const UnicodeString &srcText)
operator=(const S &src)
operator=(UnicodeString &&src) noexcept
operator=(char16_t ch)
operator=(UChar32 ch)

The new one would be the templated operator=(const S &src) but which
one is it that doesn't get called? Under what circumstances? Could you
maybe provide a snippet of example code that shows the problem?

--
Fredrik Roubert
rou...@google.com
Reply all
Reply to author
Forward
0 new messages