All kinds of pointers including pointer-to-function, pointer-to-member, pointer-to-member-function; arithmetic types; anything with a 1-arg int
constructor; anything with a 1-arg constructor taking a type that 0
can be implicitly converted to. Probably something else I haven't thought of.
Assuming that iterator_traits
resolves to std::iterator_traits
, then typename iterator_traits<Iterator>::difference_type*
is certainly a pointer-to-object type, except perhaps in a program that has an incorrect specialization of iterator_traits
. So yes, the cast works.
If you messed up and defined difference_type
or value_type
as a reference type, or not a type at all, then you'd have problems with that code.