ICU 78.3 78.3

Data Structures | Namespaces | Macros | Functions | Variables
char16ptr.h File Reference

C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types. More...

`#include "unicode/utypes.h"`
`#include <cstddef>`
`#include <string_view>`
`#include <type_traits>`

Go to the source code of this file.

## Data Structures
class | icu::Char16Ptr
| char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types. More...
class | icu::ConstChar16Ptr
| const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types. More...

## Namespaces
| icu
| File coll.h.

## Macros
#define | U_ALIASING_BARRIER(ptr)
| Barrier for pointer anti-aliasing optimizations even across function boundaries. More...

## Functions
template<typename T , typename = std::enable_if_t<std::is_same_v<T, UChar>>>
const char16_t * | U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUChar (const T *p)
const char16_t * | U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUint16 (const uint16_t *p)
const UChar * | U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr (const char16_t *p)
| Converts from const char16_t * to const UChar *. More...
UChar * | U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr (char16_t *p)
| Converts from char16_t * to UChar *. More...
const OldUChar * | U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr (const char16_t *p)
| Converts from const char16_t * to const OldUChar *. More...
OldUChar * | U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr (char16_t *p)
| Converts from char16_t * to OldUChar *. More...
std::u16string_view | icu::internal::toU16StringView (std::u16string_view sv)
| Pass-through overload. More...
std::u16string_view | icu::internal::toU16StringView (std::basic_string_view< uint16_t > sv)
| Basically undefined behavior but sometimes necessary conversion from std::basic_string_view<uint16_t> to std::u16string_view. More...
template<typename T , typename = typename std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>>>
std::u16string_view | icu::internal::toU16StringViewNullable (const T &text)
| Pass-through overload. More...
template<typename T , typename = typename std::enable_if_t<std::is_pointer_v<std::remove_reference_t<T>>>, typename = void>
std::u16string_view | icu::internal::toU16StringViewNullable (const T &text)
| In case of nullptr, return an empty view. More...

## Variables
template<typename T >
constexpr bool | icu::ConvertibleToU16StringView
| Is T convertible to a std::u16string_view or some other 16-bit string view? More...

## Detailed Description

C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.

Also conversion functions from char16_t * to UChar * and OldUChar *.

Definition in file char16ptr.h.

## Macro Definition Documentation

## ◆ U_ALIASING_BARRIER

#define U_ALIASING_BARRIER | ( |  | ptr | ) |

Barrier for pointer anti-aliasing optimizations even across function boundaries.

Internal:
  Do not use. This API is for internal use only.

Definition at line 37 of file char16ptr.h.

## Function Documentation

## ◆ toOldUCharPtr() [1/2]

OldUChar* U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr | ( | char16_t * | p | ) |
| inline

Converts from char16_t * to OldUChar *.

Includes an aliasing barrier if available.

Parameters

  p | pointer

Returns
  p as OldUChar *

Stable:
  ICU 59

Definition at line 363 of file char16ptr.h.

References U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr(), and U_ALIASING_BARRIER.

## ◆ toOldUCharPtr() [2/2]

const OldUChar* U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr | ( | const char16_t * | p | ) |
| inline

Converts from const char16_t * to const OldUChar *.

Includes an aliasing barrier if available.

Parameters

  p | pointer

Returns
  p as const OldUChar *

Stable:
  ICU 59

Definition at line 349 of file char16ptr.h.

References U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr(), and U_ALIASING_BARRIER.

Referenced by U_ICU_NAMESPACE_OR_INTERNAL::toOldUCharPtr().

## ◆ toU16StringView() [1/2]

std::u16string_view icu::internal::toU16StringView | ( | std::basic_string_view< uint16_t > | sv | ) |
| inline

Basically undefined behavior but sometimes necessary conversion from std::basic_string_view<uint16_t> to std::u16string_view.

Internal:
  Do not use. This API is for internal use only.

Definition at line 408 of file char16ptr.h.

References icu::internal::toU16StringView().

## ◆ toU16StringView() [2/2]

std::u16string_view icu::internal::toU16StringView | ( | std::u16string_view | sv | ) |
| inline

Pass-through overload.

Internal:
  Do not use. This API is for internal use only.

Definition at line 400 of file char16ptr.h.

References icu::internal::toU16StringView().

Referenced by icu::internal::toU16StringView(), and icu::internal::toU16StringViewNullable().

## ◆ toU16StringViewNullable() [1/2]

template<typename T , typename = typename std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>>>

std::u16string_view icu::internal::toU16StringViewNullable | ( | const T & | text | ) |
| inline

Pass-through overload.

Internal:
  Do not use. This API is for internal use only.

Definition at line 430 of file char16ptr.h.

References icu::internal::toU16StringView(), and icu::internal::toU16StringViewNullable().

Referenced by icu::internal::toU16StringViewNullable().

## ◆ toU16StringViewNullable() [2/2]

template<typename T , typename = typename std::enable_if_t<std::is_pointer_v<std::remove_reference_t<T>>>, typename = void>

std::u16string_view icu::internal::toU16StringViewNullable | ( | const T & | text | ) |
| inline

In case of nullptr, return an empty view.

Internal:
  Do not use. This API is for internal use only.

Definition at line 441 of file char16ptr.h.

References icu::internal::toU16StringView(), and icu::internal::toU16StringViewNullable().

## ◆ toUCharPtr() [1/2]

UChar* U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr | ( | char16_t * | p | ) |
| inline

Converts from char16_t * to UChar *.

Includes an aliasing barrier if available.

Parameters

  p | pointer

Returns
  p as UChar *

Stable:
  ICU 59

Definition at line 335 of file char16ptr.h.

References U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(), and U_ALIASING_BARRIER.

## ◆ toUCharPtr() [2/2]

const UChar* U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr | ( | const char16_t * | p | ) |
| inline

Converts from const char16_t * to const UChar *.

Includes an aliasing barrier if available.

Parameters

  p | pointer

Returns
  p as const UChar *

Stable:
  ICU 59

Definition at line 321 of file char16ptr.h.

References U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr(), and U_ALIASING_BARRIER.

Referenced by U_ICU_NAMESPACE_OR_INTERNAL::toUCharPtr().

## ◆ uprv_char16PtrFromUChar()

template<typename T , typename = std::enable_if_t<std::is_same_v<T, UChar>>>

const char16_t* U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUChar | ( | const T * | p | ) |
| inline

Internal:
  Do not use.

This API is for internal use only.

Definition at line 272 of file char16ptr.h.

References U_ALIASING_BARRIER, and U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUChar().

Referenced by U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUChar().

## ◆ uprv_char16PtrFromUint16()

const char16_t* U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUint16 | ( | const uint16_t * | p | ) |
| inline

Internal:
  Do not use.

This API is for internal use only.

Definition at line 288 of file char16ptr.h.

References U_ALIASING_BARRIER, and U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUint16().

Referenced by U_ICU_NAMESPACE_OR_INTERNAL::uprv_char16PtrFromUint16().