bool_accumulate.h
00001
00002
00003
00004
00005 #ifndef BOOL_ACCUMULATE
00006 #define BOOL_ACCUMULATE
00007
00008 namespace cwidget
00009 {
00010 namespace util
00011 {
00015 struct accumulate_and
00016 {
00017 typedef bool result_type;
00018 template<typename T_iterator>
00019 result_type operator()(T_iterator first, T_iterator last) const
00020 {
00021 for(; first!=last; ++first)
00022 if(!*first)
00023 return false;
00024
00025 return true;
00026 }
00027 };
00028
00032 struct accumulate_or
00033 {
00034 typedef bool result_type;
00035 template<typename T_iterator>
00036 result_type operator()(T_iterator first, T_iterator last) const
00037 {
00038 for(; first!=last; ++first)
00039 if(*first)
00040 return true;
00041
00042 return false;
00043 }
00044 };
00045 }
00046 }
00047
00048 #endif