1312. vector::data no longer returns a raw pointer

Section: [vector.data] Status: C++11 Submitter: Alisdair Meredith Opened: 2010-02-07 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [vector.data].

View all issues with C++11 status.


The original intent of vector::data was to match array::data in providing a simple API with direct access to the contiguous buffer of elements that could be passed to a "classic" C API. At some point, the return type became the 'pointer' typedef, which is not derived from the allocator via allocator traits - it is no longer specified to precisely T *. The return type of this function should be corrected to no longer use the typedef.

[ 2010-02-10 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Proposed resolution:

26.3.11 [vector]

Update the class definition in p2:

// data access
pointerT * data();
const_pointerconst T * data() const; [vector.data]

Adjust signatures:

pointerT * data();
const_pointerconst T * data() const;