std::experi..._iterator_t(3)
π NAME π
Hey bestie π welcome to the std::experi..._iterator_t(3) page from the C++ Standard Libary corner of the manual. We're talking about std::experimental::ranges::dangling and std::experimental::ranges::safe_iterator_t, and yes the name line is a little extra, because it lists them like this:
std::experimental::ranges::dangling,std::experimental::ranges::safe_iterator_tstd::experimental::ranges::dangling,std::experimental::ranges::safe_iterator_t
The page literally repeats the same NAME line twice, so we kept both π«Ά. No cap, that's just the vibe of this manpage.
β¨ Synopsis β¨
Defined in header <experimental/ranges/iterator> π¦. Here's the synopsis exactly as the page gives it, including those (ranges TS) markers:
Defined in header <experimental/ranges/iterator>
template< CopyConstructible T >
class dangling {
public:
dangling() requires DefaultConstructible<T>();
(ranges TS)
dangling(T t);
T get_unsafe() const;
};
template< Range R >
using safe_iterator_t =
std::conditional_t<std::is_lvalue_reference<R>::value,
(ranges TS)
ranges::iterator_t<R>,
ranges::dangling<ranges::iterator_t<R>>;
The class template dangling is a simple wrapper around an object, and its whole job is to say: βhey, the wrapped object may be danglingβ π. That means it refers to another object whose lifetime may have ended. Itβs giving little warning-label energy, not main-character energy.
The alias template safe_iterator_t returns the iterator type of R, wrapped in dangling if the range was an rvalue range (as indicated by R not being an lvalue reference type). So if R is not an lvalue reference type, that's the signal π
.
They are used by range algorithms that accept rvalue ranges and return iterators into them. Periodt.
πΈ Member functions πΈ
std::experimental::ranges::dangling::dangling
dangling() requires DefaultConstructible<T>(); (1)
dangling(T t); (2)
- Default constructor. Value-initializes the wrapped object β¨.
- Initializes the wrapped object with
t. Note that this constructor defines an implicit conversion fromTtodangling<T>π.
std::experimental::ranges::dangling::get_unsafe
T get_unsafe() const;
Returns a copy of the wrapped object. That's it, bestie β just a copy π.
okay love u bye π
this iconic page comes from http://cppreference.com, dated 2024.06.10, and its title is std::experi..._iterator_t(3). periodt π¦π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms