3

I believe this is relatively new that an iterator class is required to have the following tags at the top of the class:

using iterator_category = std::bidirectional_iterator_tag;
using value_type = T;
using difference_type = int;
using pointer = T*;
using reference = T&;

Why are these necessary and what are they doing behind the scenes? (if anything)

polar
  • 194
  • 1
  • 15

1 Answers1

2

The using keyword is new in C++11.

In this instance, it's being used as a replacement for typedef.

Instead of writing:

typedef T value_type;

You can write this to get the same result:

using value_type = T;

See What is the logic behind the "using" keyword in C++? for more info.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Marshall Clow
  • 15,972
  • 2
  • 29
  • 45