operator- (std::counted_iterator<I>, std::default_sentinel_t)
From cppreference.net
<
cpp
|
iterator
|
counted iterator
C++
Iterator library
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::counted_iterator
| Member functions | ||||
| Non-member functions | ||||
|
(C++20)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
operator-
(default_sentinel_t)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
| Helper classes | ||||
|
friend
constexpr
std::
iter_difference_t
<
I
>
operator
-
(
const counted_iterator & x, std:: default_sentinel_t ) ; |
(1) | (начиная с C++20) |
|
friend
constexpr
std::
iter_difference_t
<
I
>
operator
-
(
std:: default_sentinel_t , const counted_iterator & y ) ; |
(2) | (начиная с C++20) |
1)
Возвращает отрицательное расстояние до конца.
2)
Возвращает положительное расстояние до конца.
Этот шаблон функции не видим для обычного unqualified или qualified lookup , и может быть найден только с помощью argument-dependent lookup , когда std::counted_iterator<I> является ассоциированным классом аргументов.
Содержание |
Параметры
| x, y | - | адаптеры итераторов для вычисления разности |
Возвращаемое значение
1)
-
x.
count
(
)
2)
y.
count
(
)
Пример
Запустить этот код
#include <initializer_list> #include <iterator> int main() { constexpr static auto v = {1, 2, 3, 4}; constexpr std::counted_iterator<std::initializer_list<int>::iterator> it{v.begin(), 3}; constexpr auto d1 = it - std::default_sentinel; static_assert(d1 == -3); // (1) constexpr auto d2 = std::default_sentinel - it; static_assert(d2 == +3); // (2) }
Смотрите также
увеличивает или уменьшает
counted_iterator
(public member function) |
|
|
(C++20)
|
увеличивает итератор
(function template) |
|
(C++20)
|
вычисляет расстояние между двумя адаптерами итераторов
(function template) |
|
(C++20)
|
стандартный страж для использования с итераторами, которые знают границу своего диапазона
(class) |