unicode_scalar_value¶
If ZTD_TEXT_UNICODE_SCALAR_VALUE_DISTINCT_TYPE is turned on, this type definition points to an internal class which implements the invariant of being a unicode scalar value. Otherwise, it is simply char32_t
.
A unicode scalar value is stored as an at least 32-bit value, but may occupy more space depending on the architecture. It requires 21 bits of space to fit the required unicode code point definition. If the distinct type is used, then this type will trap (abort
/assert
) if the value is greater than the allowed 21 bits, or if the value results in one of the Unicode Surrogate Pair values used for UTF-16 encoding and decoding. Not recommended for ztd::text::wtf8 usage, as that encoding produces Unicode Surrogate Pair values intentionally.
-
typedef char32_t ztd::text::unicode_scalar_value¶
Internal Type¶
Warning
⚠️ Names with double underscores, and within the __detail
and __impl
namespaces are reserved for the implementation. Referencing this entity directly is bad, and the name/functionality can be changed at any point in the future. Relying on anything not guaranteed by the documentation is ☢️☢️Undefined Behavior☢️☢️.
-
class ztd::text::__txt_impl::__unicode_scalar_value¶
A 32-bit value that is within the allowed 21 bits of Unicode and is not one of the Surrogate values.
- Remark
The invariant is enforced with an assertion in normal modes, and can optionally be enforced by turning on
ZTD_TEXT_UNICODE_SCALAR_VALUE_INVARIANT_ABORT.
Public Functions
-
__unicode_scalar_value() noexcept = default¶
Constructs a scalar value of indeterminate value (if no parentheses/brackets are provided) or with the value 0 (if parentheses/brackets are provided for intentional value initialization).
-
inline constexpr __unicode_scalar_value(char32_t __code_point) noexcept¶
Constructs a scalar value with the given code point value.
- Remark
-
inline explicit constexpr operator char32_t() const noexcept¶
An explicit conversion to a typical char32_t value, bit-compatible with a normal code point value.
-
inline constexpr const char32_t &value() const & noexcept¶
Retrieves the underlying value.
-
inline constexpr char32_t &value() & noexcept¶
Retrieves the underlying value.
-
inline constexpr char32_t &&value() && noexcept¶
Retrieves the underlying value.