I have a function (composition of Thrust algorithms) templateized by OutputIterator type of obeg parameter. Initial length of output container is unknown.
template< typename InputIterator, typename OutputIterator >
OutputIterator f(InputIterator beg, InputIterator end, OutputIterator obeg)
{
...
return thrust::algorithm(temp.cbegin(), temp.cend(), obeg);
}
What I want is to call this function first time to determine the required length of obeg sequence. Then I want to allocate output vector of the length. After all I want to call f again, but pass output.begin() as obeg. The function is pure.
Can I use thrust::counting_iterator as output iterator to determine the length of output of an algorithm? Can it behave just like thrust::discard_iterator with respect to assignment to dereferenced value (which should be like a std::ignore from , but with operator Incrementable () const overloading)? I need only its counting capabilities in the case.