# std::ranges::dangling

From cppreference.com
< cpp‎ | ranges

Defined in header `<ranges>` |  |
struct dangling; |  | (since C++20)

`dangling` is a placeholder type and an empty class type, used together with the template aliases `ranges::safe_iterator_t` and `ranges::safe_subrange_t`.

When some constrain algorithms that usually return an iterator or a subrange of a `Range` take a particular rvalue `Range` argument that does not models exposition-only concept `__ForwardingRange`, `dangling` will be returned instead to avoid returning potentially dangling results.

### Member functions

## std::ranges::dangling::dangling

constexpr dangling() noexcept = default; | (1) |
template<class... Args> constexpr dangling(Args&&...) noexcept { } | (2) |

1) `dangling` is trivially default constructible.
2) `dangling` can be constructed from arguments of arbitrary number and arbitrary non-void type. The construction does not have any side-effect itself.

In other words, after replacing the type (e.g. an iterator type) in a well-formed non-aggregate initialization with `dangling`, the resulting initialization is also well-formed.

### Example

| This section is incomplete Reason: no example

### See also

safe_iterator_t safe_subrange_t | obtains iterator type or `subrange` type of a `Range` which also models `__ForwardingRange` (alias template)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/dangling&oldid=110606"