I think your current code is very nearly fine. If I were writing this, I'd use declval
rather than (T*)0
, and I'd use the dereference operator rather than operator->
:
template <typename T>
using pointed_to_type_t =
typename std::remove_reference<decltype(*std::declval<T>())>::type;
template <typename T_it>
class deref_iterator {
typedef pointed_to_type_t<
typename std::iterator_traits<T_it>::value_type> value_type;
};