I have a template function that takes the following form:
template < class ITER1, class ITER2 >
bool example(ITER1 Input1, ITER1 Input2, ITER2 Output)
{
ITER2 OrigOutput(Output);
// ...
std::copy(Input1, Input2, Output);
return (OrigOutput != Output);
}
And I'm calling example()
like this:
std::vector < int > Input;
std::set < int > Output;
if (example(Input.begin(), Input.end(), inserter(Output, Output.begin())))
{
...
}
I'd like example()
to return true
if elements have been inserted into Output
, however I'm getting a compile error (msvc 2008):
Error 1 error C2678: binary '!=' : no operator found which takes a left-hand
operand of type 'std::insert_iterator<_Container>' (or there is no acceptable
conversion)
Is there a way I can determine whether any elements were inserted into the output iterator in order to return the correct bool value?