jeudi 23 juillet 2015

Why is the pointer typedef not used in std::vector::data()?

In the API of std::vector there are some typedefs and many functions which return these typedefs.

e.g.

reference operator[](size_type n);

Where reference and size_type are typedefs.

There is a typedef of pointer which it gets from it's allocator template argument. Why is the function signature of data() like this:

T* data() noexcept;

Rather than:

pointer data() noexcept;

Is there some reasoning behind this? Also why is it T* rather than value_type*.

If you want to check it is section 23.3.6.4 of the standard I have.

Aucun commentaire:

Enregistrer un commentaire