It’s time for another ‘how do i do this in c++ without loosing my grip’-question!
This time:
Considering the following code taken from cplusplus.com:
template<class InputIterator, class OutputIterator>
OutputIterator copy ( InputIterator first, InputIterator last, OutputIterator result )
{
while (first!=last) *result++ = *first++;
return result;
}
Is there a way to cast *first to the type of *result?
In other words: is there a way to determine (at compiletime) the type of result?
yes, the type of
*resultis (’cause the type ofresultisOutputIterator)of course, if OutputIterator is a pointer or a correctly written STL-compatible iterator. Otherwise, no, I think there is no way.
In the upcoming C++0x, it would be much easier, that is,
HTH,
Armen