std::ranges::none_of
Актуально для C++26.
#include <algorithm>
Актуально на 2025-05-08.
Define overload #1
template<input_iterator I, sentinel_for<I> S, class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {});
Вернёт true, если ни один элемент из диапазона [first, last], не удовлетворяет условия предиката "pred".
Иначе, вернёт false.
Example, possible implementation
Define overload #2
template<input_range R, class Proj = identity, indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {});
Вернёт true, если ни один элемент из диапазона "r", не удовлетворяет условия предиката "pred".
Иначе, вернёт false.
Example, possible implementation
Notes
- Если входящая последовательность пустат, будет возвращено значение true.
- Алгоритм завершит работу как только встретится первый элемент, для которого предикат возвратит true.
- Перебор элементов начинается с начала последовательности.
Examples
Example 1:
#include <iostream>
#include <algorithm>
namespace ranges = std::ranges;
int main()
{
auto list = {'D', 'i', 'R', 'f'};
auto no_upper = ranges::none_of(std::begin(list), std::end(list), [](unsigned char s) { return std::isupper(s); });
auto no_lower = ranges::none_of(std::begin(list), std::end(list), [](unsigned char s) { return std::islower(s); });
auto no_digit = ranges::none_of(std::begin(list), std::end(list), [](unsigned char s) { return std::isdigit(s); });
std::cout << std::boolalpha;
std::cout << no_upper << std::endl;
std::cout << no_lower << std::endl;
std::cout << no_digit << std::endl;
}
false false true
Changelog
C++20
Введён в стандарт.See also
TODO
This page was last modified on 2025-05-08