Given:
struct Iter {
using value_type = int;
using difference_type = int;
using reference = int;
using pointer = int;
using iterator_category = int;
};
The following works fine with libstC ++, but does not compile in libC ++ 5.0.0:
#include <iterator>
#include <type_traits>
static_assert(
std::is_same<
std::iterator_traits<Iter>::iterator_category,
Iter::iterator_category
>::value, "");
With an error:
error: no member named ' iterator_category' in ' std::__1::iterator_traits<Iter>' std::is_same<std::iterator_traits<Iter>::iterator_category, Iter::iterator_category>::value, "");
A static statement succeeds if it Iter::iterator_categoryis one of the standard input categories, for example. std::input_iterator_tag.
IMHO this should not fail, because the C ++ project is indicated in [iterator.traits] # 2 :
If Iterator has a valid ( [temp.deduct] ) types of members difference_type, value_type, pointer, reference, and iterator_category, iterator_traits<Iterator>should have the following public items:
using difference_type = typename Iterator::difference_type;
using value_type = typename Iterator::value_type;
using pointer = typename Iterator::pointer;
using reference = typename Iterator::reference;
using iterator_category = typename Iterator::iterator_category;
iterator_traits<Iterator> .
- , ?