GeezerVison is showing cpprefjp.github.io — std::all_of - cpprefjp C++日本語リファレンス
最終更新日時:
2026年09月11日 13時06分31秒 (JST)
Akira Takahashi
が更新
履歴
編集
function template
<algorithm>
std:: all_of (C++11)
namespace std {
template < class InputIterator , class Predicate >
bool all_of ( InputIterator first ,
InputIterator last ,
Predicate pred ); // (1) C++11
template < class InputIterator , class Predicate >
constexpr bool all_of ( InputIterator first ,
InputIterator last ,
Predicate pred ); // (1) C++20
template < class ExecutionPolicy , class ForwardIterator , class Predicate >
bool all_of ( ExecutionPolicy && exec ,
ForwardIterator first ,
ForwardIterator last ,
Predicate pred ); // (2) C++17
}
概要
イテレータ範囲[first, last)の全ての要素が条件を満たすかを判定する。
戻り値
[first,last) が空であったり、[first,last) 内の全てのイテレータ i について pred(*i) が true である場合は true を返し、そうでない場合は false を返す。
計算量
最大で last - first 回 pred を実行する。
例
出力
true
false
実装例
template < class InputIterator , class Predicate >
bool all_of ( InputIterator first , InputIterator last , Predicate pred ) {
for ( ; first != last ; ++ first )
if ( ! bool ( pred ( * first ))) return false ;
return true ;
}
バージョン
言語
処理系
関連項目
参照