12#if U_SHOW_CPLUSPLUS_API
32#ifdef U_ALIASING_BARRIER
34#elif (defined(__clang__) || defined(__GNUC__)) && U_PLATFORM != U_PF_BROWSER_NATIVE_CLIENT
35# define U_ALIASING_BARRIER(ptr) asm volatile("" : : "rm"(ptr) : "memory")
36#elif defined(U_IN_DOXYGEN)
37# define U_ALIASING_BARRIER(ptr)
52#if !U_CHAR16_IS_TYPEDEF
60#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
86 inline char16_t *
get()
const;
92 inline operator char16_t *()
const {
return get(); }
97#ifdef U_ALIASING_BARRIER
98 template<
typename T>
static char16_t *cast(T *t) {
100 return reinterpret_cast<char16_t *
>(t);
114#ifdef U_ALIASING_BARRIER
116Char16Ptr::Char16Ptr(
char16_t *p) : p_(p) {}
117#if !U_CHAR16_IS_TYPEDEF
120#if U_SIZEOF_WCHAR_T==2
133#if !U_CHAR16_IS_TYPEDEF
136#if U_SIZEOF_WCHAR_T==2
159#if !U_CHAR16_IS_TYPEDEF
167#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
194 inline const char16_t *
get()
const;
200 inline operator const char16_t *()
const {
return get(); }
205#ifdef U_ALIASING_BARRIER
206 template<
typename T>
static const char16_t *cast(
const T *t) {
208 return reinterpret_cast<const char16_t *
>(t);
222#ifdef U_ALIASING_BARRIER
225#if !U_CHAR16_IS_TYPEDEF
228#if U_SIZEOF_WCHAR_T==2
241#if !U_CHAR16_IS_TYPEDEF
244#if U_SIZEOF_WCHAR_T==2
263#ifdef U_ALIASING_BARRIER
266 return reinterpret_cast<const UChar *
>(p);
277#ifdef U_ALIASING_BARRIER
280 return reinterpret_cast<UChar *
>(p);
291#ifdef U_ALIASING_BARRIER
294 return reinterpret_cast<const OldUChar *
>(p);
305#ifdef U_ALIASING_BARRIER
308 return reinterpret_cast<OldUChar *
>(p);
311#ifndef U_FORCE_HIDE_INTERNAL_API
318 std::is_convertible_v<T, std::u16string_view>
319#if !U_CHAR16_IS_TYPEDEF && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 180000)
320 || std::is_convertible_v<T, std::basic_string_view<uint16_t>>
322#if U_SIZEOF_WCHAR_T==2
323 || std::is_convertible_v<T, std::wstring_view>
334#if !U_CHAR16_IS_TYPEDEF && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 180000)
345#if U_SIZEOF_WCHAR_T==2
351inline std::u16string_view toU16StringView(std::wstring_view sv) {
361 typename =
typename std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>>>
371 typename =
typename std::enable_if_t<std::is_pointer_v<std::remove_reference_t<T>>>,
374 if (text ==
nullptr)
return {};
std::u16string_view toU16StringView(std::u16string_view sv)
Pass-through overload.
std::u16string_view toU16StringViewNullable(const T &text)
Pass-through overload.
#define U_ALIASING_BARRIER(ptr)
Barrier for pointer anti-aliasing optimizations even across function boundaries.
char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
Char16Ptr(std::nullptr_t p)
nullptr constructor.
Char16Ptr(uint16_t *p)
Converts the pointer to char16_t *.
Char16Ptr(wchar_t *p)
Converts the pointer to char16_t *.
Char16Ptr(char16_t *p)
Copies the pointer.
char16_t * get() const
Pointer access.
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
ConstChar16Ptr(const char16_t *p)
Copies the pointer.
ConstChar16Ptr(const uint16_t *p)
Converts the pointer to char16_t *.
~ConstChar16Ptr()
Destructor.
const char16_t * get() const
Pointer access.
ConstChar16Ptr(const wchar_t *p)
Converts the pointer to char16_t *.
ConstChar16Ptr(const std::nullptr_t p)
nullptr constructor.
constexpr bool ConvertibleToU16StringView
Is T convertible to a std::u16string_view or some other 16-bit string view?
const OldUChar * toOldUCharPtr(const char16_t *p)
Converts from const char16_t * to const OldUChar *.
const UChar * toUCharPtr(const char16_t *p)
Converts from const char16_t * to const UChar *.
char16_t UChar
The base type for UTF-16 code units and pointers.
uint16_t OldUChar
Default ICU 58 definition of UChar.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.