ICU4C 79
Loading...
Searching...
No Matches
U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range > Class Template Reference

A C++ "range" for non-validating iteration over all of the code points of a code unit range. More...

#include <utfiterator.h>

Public Member Functions

 UnsafeUTFStringCodePoints ()=default
 Constructs an empty C++ "range" object.
template<typename R = Range, typename = std::enable_if_t<!std::is_reference_v<R>>>
 UnsafeUTFStringCodePoints (Range unitRange)
 Constructs a C++ "range" object over the code points in the string.
template<typename R = Range, typename = std::enable_if_t<std::is_reference_v<R>>, typename = void>
 UnsafeUTFStringCodePoints (Range unitRange)
 Constructs a C++ "range" object over the code points in the string, keeping a reference to the code unit range.
 UnsafeUTFStringCodePoints (const UnsafeUTFStringCodePoints &other)=default
 Copy constructor.
UnsafeUTFStringCodePoints & operator= (const UnsafeUTFStringCodePoints &other)=default
 Copy assignment operator.
auto begin ()
template<typename R = Range, typename = std::enable_if_t<prv::range<const R>>>
auto begin () const
auto end ()
template<typename R = Range, typename = std::enable_if_t<prv::range<const R>>>
auto end () const
auto rbegin () const
auto rend () const
auto front () const
 Returns the CodeUnits for the first character/code point.
auto back () const
 Returns the CodeUnits for the last character/code point.

Detailed Description

template<typename CP32, typename Range>
class U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >

A C++ "range" for non-validating iteration over all of the code points of a code unit range.

The string must be well-formed.

Call unsafeUTFStringCodePoints() to have the compiler deduce the Range type.

UnsafeUTFStringCodePoints is conditionally borrowed; that is, if Range is a borrowed range so is UnsafeUTFStringCodePoints<CP32, behavior, Range>. Note that when given a range r that is an lvalue and is not a view, unsafeUTFStringCodePoints(r) uses a ref_view of r as the Range type, which is a borrowed range. In practice, this means that given a container variable r, the iterators of unsafeUTFStringCodePoints(r) can be used as long as iterators on r are valid, without having to keep unsafeUTFStringCodePoints(r) around. For instance:

std::u8string s = "𒇧𒇧";
// it outlives unsafeUTFStringCodePoints<char32_t>(s).
++it;
char32_t second_code_point = it->codePoint(); // OK.
constexpr UnsafeUTFStringCodePointsAdaptor< CP32 > unsafeUTFStringCodePoints
Range adaptor function object returning an UnsafeUTFStringCodePoints object that represents a "range"...
Template Parameters
CP32Code point type: UChar32 (=int32_t) or char32_t or uint32_t
RangeA C++ "range" of Unicode UTF-8/16/32 code units
Draft
This API may be changed in the future versions and was introduced in ICU 78
See also
unsafeUTFStringCodePoints

Definition at line 2586 of file utfiterator.h.

Constructor & Destructor Documentation

◆ UnsafeUTFStringCodePoints() [1/4]

template<typename CP32, typename Range>
U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::UnsafeUTFStringCodePoints ( )
default

Constructs an empty C++ "range" object.

Draft
This API may be changed in the future versions and was introduced in ICU 78

Referenced by operator=(), and UnsafeUTFStringCodePoints().

◆ UnsafeUTFStringCodePoints() [2/4]

template<typename CP32, typename Range>
template<typename R = Range, typename = std::enable_if_t<!std::is_reference_v<R>>>
U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::UnsafeUTFStringCodePoints ( Range unitRange)
inlineexplicit

Constructs a C++ "range" object over the code points in the string.

Parameters
unitRangeinput range
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2601 of file utfiterator.h.

◆ UnsafeUTFStringCodePoints() [3/4]

template<typename CP32, typename Range>
template<typename R = Range, typename = std::enable_if_t<std::is_reference_v<R>>, typename = void>
U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::UnsafeUTFStringCodePoints ( Range unitRange)
inlineexplicit

Constructs a C++ "range" object over the code points in the string, keeping a reference to the code unit range.

This overload is used by utfStringCodePoints in C++17; in C++20, a ref_view is used instead (via views::all).

Parameters
unitRangeinput range
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2611 of file utfiterator.h.

◆ UnsafeUTFStringCodePoints() [4/4]

template<typename CP32, typename Range>
U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::UnsafeUTFStringCodePoints ( const UnsafeUTFStringCodePoints< CP32, Range > & other)
default

Copy constructor.

Draft
This API may be changed in the future versions and was introduced in ICU 78

References UnsafeUTFStringCodePoints().

Member Function Documentation

◆ back()

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::back ( ) const
inline

Returns the CodeUnits for the last character/code point.

Requires that the range is not empty.

Returns
the CodeUnits for the last character/code point.
Draft
This API may be changed in the future versions and was introduced in ICU 79

Definition at line 2701 of file utfiterator.h.

References end().

◆ begin() [1/2]

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::begin ( )
inline
Returns
the range start iterator
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2623 of file utfiterator.h.

Referenced by front(), and rend().

◆ begin() [2/2]

template<typename CP32, typename Range>
template<typename R = Range, typename = std::enable_if_t<prv::range<const R>>>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::begin ( ) const
inline
Returns
the range start iterator
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2632 of file utfiterator.h.

◆ end() [1/2]

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::end ( )
inline
Returns
the range limit (exclusive end) iterator
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2640 of file utfiterator.h.

Referenced by back(), and rbegin().

◆ end() [2/2]

template<typename CP32, typename Range>
template<typename R = Range, typename = std::enable_if_t<prv::range<const R>>>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::end ( ) const
inline
Returns
the range limit (exclusive end) iterator
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2656 of file utfiterator.h.

◆ front()

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::front ( ) const
inline

Returns the CodeUnits for the first character/code point.

Requires that the range is not empty.

Returns
the CodeUnits for the first character/code point.
Draft
This API may be changed in the future versions and was introduced in ICU 79

Definition at line 2690 of file utfiterator.h.

References begin().

◆ operator=()

template<typename CP32, typename Range>
UnsafeUTFStringCodePoints & U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::operator= ( const UnsafeUTFStringCodePoints< CP32, Range > & other)
default

Copy assignment operator.

Draft
This API may be changed in the future versions and was introduced in ICU 78

References UnsafeUTFStringCodePoints().

◆ rbegin()

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::rbegin ( ) const
inline
Returns
std::reverse_iterator(end())
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2671 of file utfiterator.h.

References end().

◆ rend()

template<typename CP32, typename Range>
auto U_HEADER_ONLY_NAMESPACE::UnsafeUTFStringCodePoints< CP32, Range >::rend ( ) const
inline
Returns
std::reverse_iterator(begin())
Draft
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 2679 of file utfiterator.h.

References begin().


The documentation for this class was generated from the following file: