次の関数オブジェクトを定義しました。
struct Predicate1
{
__device__ bool operator ()
(const DereferencedIteratorTuple& lhs, const DereferencedIteratorTuple& rhs)
{
using thrust::get;
//if you do <=, returns last occurence of largest element. < returns first
if (get<0>(lhs)== get<2>(lhs) && get<0>(lhs)!= 3) return get<1>(lhs) < get<1>(rhs);
else
return true ;
}
};
ここで、DereferencedIteratorTuple は次のとおりです。
typedef thrust::tuple<int, float,int> DereferencedIteratorTuple;
さらに、私はそれを次のように呼びます:
result = thrust::max_element(iter_begin, iter_end, Predicate1());
しかし、結果はタプル (3,.99,4) です。このタプルの条件get<0>(lhs)== get<2>(lhs)
が成り立たないため、なぜこれが結果になるのか混乱しています。if
したがって、演算子は、このタプルのすべての比較に対して true を返します。ただし、thrust::max_element
次のように定義されます。
「このバージョンは、関数オブジェクト comp を使用してオブジェクトを比較します。具体的には、このバージョンの max_element は、[first, last) の最初の反復子 i を返します。[first, last) のすべての反復子 j に対して、comp(*i, *j)は偽です。」
したがって、このタプルに関してこれを選択する方法はなく、演算子は決して false を返しません。私が間違っていることを教えてください