C++ Ranges::dangling, sized_range, disable_sized range Introduction














































C++ Ranges::dangling, sized_range, disable_sized range Introduction



In this series of articles on RANGES with C++, today we are going to see libraries of std::ranges::dangling , std::ranges::sized range and std::ranges::disable_sized range
____________________________________________________________________________________

INTRODUCTION to RANGES LIBRARY HAS BEEN DONE IN MY FIRST ARTICLE OF RANGES LIBRARY

All the libraries defined below are included in the header <ranger> and <iterator>.


std::ranges::dangling


It is a  wrapper for an iterator into a range that may no longer be valid/dangling.

It indicates that an iterator/subrange should not return as it would be dangling.


Public Member Functions of dangling library are::

1.constexpr  dangling (I it)    Implicit converting constructor.
 
2.constexpr I get_unsafe () constant (get_unsafe() returns the iterator from which this dangling object was constructed.)

std::ranges::sized range

It specifies the requirements of a range type that knows its size in constant time with the size function.

std::ranges::disable_sized range

It allows use of range types that provide a size function  but do not model size_range.
However,
 It cannot be used to opt out a range whose iterator and sentinel satisfy sized_sentinel_for:


Comments