在 c++ 20 中提出,一些算法是 constexpr。
例如:
template< class InputIt, class UnaryPredicate >
bool all_of( InputIt first, InputIt last, UnaryPredicate p );
(since C++11)
(until C++20)
template< class InputIt, class UnaryPredicate >
constexpr bool all_of( InputIt first, InputIt last, UnaryPredicate p );
(since C++20)
虽然我们知道迭代器通常不是 constexpr。我认为这仅在 constexpr 容器的情况下才有用。有人可以澄清我是否遗漏了什么以及我的理解是否正确?