iterator-traits

specializing iterator_traits

别等时光非礼了梦想. 提交于 2019-11-27 06:10:02
问题 I'd like to specialize std::iterator_traits<> for iterators of a container class template that does not have the usual nested typedefs (like value_type , difference_type , etc.) and whose source I shouldn't modify. Basically I'd like to do something like this: template <typename T> struct iterator_traits<typename Container<T>::iterator> { typedef T value_type; // etc. }; except that this doesn't work, as the compiler is unable to deduce T from Container<T>::iterator . Is there any working way

Contiguous iterator detection

亡梦爱人 提交于 2019-11-26 23:00:43
问题 C++17 introduced the concept of ContiguousIterator http://en.cppreference.com/w/cpp/iterator. However it doesn't seem that there are plans to have a contiguous_iterator_tag (in the same way we now have random_access_iterator_tag ) reported by std::iterator_traits<It>::iterator_category . Why is contiguous_iterator_tag missing? Is there a conventional protocol to determine if an iterator is Contiguous? Or a compile time test? In the past I mentioned that for containers if there is a .data()