How to retrieve value type from iterator in C++?

typename std::iterator_traits<Iter>::value_type

This will work if your template is instantiated with Iter as a pointer type.

By the way, typename isn’t part of the type itself. It tells the compiler that value_type really is a type. If it were the name of a function or a static data member, then that affects the syntax. The compiler doesn’t necessarily know what it is, since the specialization of iterator_traits for Iter might not be visible when the template is compiled.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)