Namespaces
Variants
Views
Actions

no-throw-input-iterator, no-throw-forward-iterator, no-throw-sentinel-for, no-throw-input-range, no-throw-forward-range

From cppreference.com
< cpp‎ | memory
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
Dynamic memory management
Smart pointers
(C++11)
(C++11)
(C++11)
(until C++17)
(C++11)
Allocators
Memory resources
Uninitialized storage
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Garbage collection support
Miscellaneous
(C++20)
(C++11)
(C++11)
C Library
Low level memory management
 
template<class I>

concept no-throw-input-iterator = // exposition only
  std::input_iterator<I> &&
  std::is_lvalue_reference_v<std::iter_reference_t<I>> &&

  std::same_as<std::remove_cvref_t<std::iter_reference_t<I>>, std::iter_value_t<I>>;
(1) (since C++20)
template<class I>

concept no-throw-forward-iterator = // exposition only
  no-throw-input-iterator<I> &&
  std::forward_iterator<I> &&

  no-throw-sentinel-for<I, I>;
(2) (since C++20)
template<class S, class I>
concept no-throw-sentinel-for = std::sentinel_for<S, I>; // exposition only
(3) (since C++20)
template<class R>

concept no-throw-input-range = // exposition only
  ranges::range<R> &&
  no-throw-input-iterator<ranges::iterator_t<R>> &&

  no-throw-sentinel-for<ranges::sentinel_t<R>, ranges::iterator_t<R>>;
(4) (since C++20)
template<class R>

concept no-throw-forward-range = // exposition only
  no-throw-input-range<R> &&

  no-throw-forward-iterator<ranges::iterator_t<R>>;
(5) (since C++20)

These exposition-only concepts specify that no exceptions are thrown from operations required by algorithms on iterators, sentinels, and ranges.

1) The no-throw-input-iterator concept requires that dereferencing the iterator yields an lvalue, like contiguous_iterator and LegacyForwardIterator.

[edit] Semantic requirements

Like all standard concepts, every concept listed here is modeled only if all concepts it subsumes are modeled.

1) A type I models no-throw-input-iterator only if no exceptions are thrown from increment, copy construction, move construction, copy assignment, move assignment, or indirection through valid iterators.
3) Types S and I model no-throw-sentinel-for only if no exceptions are thrown from copy construction, move construction, copy assignment, move assignment, or comparisons between valid values of type I and S.
4) A type R models no-throw-input-range only if no exceptions are thrown from calls to ranges::begin and ranges::end on an object of type R.

[edit] Notes

These concepts allow some operations on iterators and sentinels to throw exceptions, e.g. operations on invalid values.

[edit] See also

specifies that a type is an input iterator, that is, its referenced values can be read and it can be both pre- and post-incremented
(concept) [edit]
specifies that an input_iterator is a forward iterator, supporting equality comparison and multi-pass
(concept) [edit]
specifies a type is a sentinel for an input_or_output_iterator type
(concept) [edit]
specifies a range whose iterator type satisfies input_iterator
(concept) [edit]
specifies a range whose iterator type satisfies forward_iterator
(concept) [edit]