FabioAng wrote:
Assuming I have this function:
template<typename OutputIterator>
void copy(const char* input, OutputIterator result)
{
while ( *input != NULL )
{
*result = *input;
++result;
++input;
}
}
I would like to cast input value to output value in this way
template<typename OutputIterator>
void copy(const char* input, OutputIterator result)
{
while ( *input != NULL )
{
*result = (cast to output value type) *input;
++result;
++input;
}
}
Output iterators don't generally have a well-defined value type that you
can get at. Technically, the requirement for an output iterator that
applies here is that the expression *iter = val; must be valid and must
copy val to the location in the output sequence that iter points to. If
you can't assign the value, then the iterator just isn't the right type.
Take a step back, and describe the problem that you're trying to solve,
rather than an attempted solution that didn't work.
--
-- Pete
Roundhouse Consulting, Ltd. (
www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (
www.petebecker.com/tr1book)