c++ - Converting arrays in stl like copy -


it's time 'how do in c++ without loosing grip'-question!

this time:

considering following code taken cplusplus.com:

template<class inputiterator, class outputiterator>   outputiterator copy ( inputiterator first, inputiterator last, outputiterator result ) {   while (first!=last) *result++ = *first++;   return result; } 

is there way cast *first type of *result?

in other words: there way determine (at compiletime) type of result?

yes, type of *result ('cause type of result outputiterator )

typename std::iterator_traits<outputiterator>::value_type 

of course, if outputiterator pointer or correctly written stl-compatible iterator. otherwise, no, think there no way. in upcoming c++0x, easier, is,

decltype(*result) 

hth,

armen


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -