all_of returns true if pred(*i) is true for every iterator i in the range [first, last) and false otherwise. any_of returns true if pred(*i) is true for any iterator i in the range [first, last) and false otherwise. none_of returns true if there is no iterator i in the range [first, last) such that pred(*i) is true, and false otherwise.
...
template <typename T>
struct is_even
{
bool operator()(T x) const restrict(amp, cpu)
{
if (((int)x) % 2)
return true;
else
return false;
}
};
template <typename T>
struct is_negative
{
bool operator()(T x) const restrict(amp, cpu)
{
if (x<0)
return true;
else
return false;
}
};
int length = 1024;
std::vector<int> vecSrc(length);
std::vector<int> vecSrc2(length);
for(int i = 0; i<length; i++)
{
vecSrc[i] = i * 2;
vecSrc2[i] = i;
}
int n = rand()% (length+1);
...
bool out3 = bolt::amp::any_of(ctrl, vecSrc.begin(), vecSrc.end(), is_negative());
bool out4 = bolt::amp::any_of(ctrl, vecSrc2.begin(), vecSrc2.end(), is_even());
bool out5 = bolt::amp::none_of(ctrl, vecSrc.begin(), vecSrc.end(), is_negative());
bool out6 = bolt::amp::none_of(ctrl, vecSrc2.begin(), vecSrc2.begin() + n, is_even());