C++ Logo


Advanced search

Re: std::any_of, std::all_of and std::none_of without predicate

From: Jake Arkinstall <jake.arkinstall_at_[hidden]>
Date: Sun, 15 Dec 2019 15:55:04 +0000
I'll be all for this idea iff the value_type of the iterator passed to
these functions is verified to be precisely of type bool, rather than the
looser "convertible to bool" requirement of the predicate return type in
the current function definitions, following the principle of least

Consider a container holding elements of type T, where T is convertible to
bool. I use std::any_of over that container and accidently miss out the
predicate, which is intended as, say, a bounds check. Without warning or
error, my code compiles and I get unwanted results.

Received on 2019-12-15 09:57:38