STL container requierments

c++, stl

Solution

The container requirements are a bit funky in the sense that they are actually not used by any generic algorithm. In that sense, it doesn't really matter much.

That said, the requirements are on the interface for containers not on how the container is actually instantiated. Even non-template classes can conform to the various requirements and, in fact, do. The requirement is that `value_type` is present; what it is defined to depends entirely on the container implementation.

Problem

Does the standard require that `some_container<T>::value_type` be `T`? I am asking because I am considering different approaches to implementing an STL-compliant 2d dynamic array. One of them is to have `2Darray<T>::value_type` be `2Darray_row<T>` or something like that, where the array would be iterated as a collection of rows (a little simplified. My actual implementation allows iteration in 3 directions)

Original source

Related problems