2566. Requirements on the first template parameter of container adaptors

Section: 26.6 [container.adaptors] Status: C++17 Submitter: Tim Song Opened: 2015-12-08 Last modified: 2017-07-30

Priority: 0

View all other issues in [container.adaptors].

View all issues with C++17 status.


As noted in this StackOverflow question, 26.6 [container.adaptors] doesn't seem to place any requirement on the first template parameter (T) of stack, queue, and priority_queue: the only use of T is in the default template argument (which need not be used) for the second template parameter (Container), while all of the operations of the adaptors are defined using Container's member typedefs.

This permits confusing and arguably nonsensical types like queue<double, deque<std::string>> or priority_queue<std::nothrow_t, vector<int>>, which presumably wasn't intended.

[2016-02, Issues Telecon]

P0; move to Tentatively Ready.

Proposed resolution:

This wording is relative to N4567.

  1. Edit 26.6.1 [container.adaptors.general]/2 as indicated:

    -2- The container adaptors each take a Container template parameter, and each constructor takes a Container reference argument. This container is copied into the Container member of each adaptor. If the container takes an allocator, then a compatible allocator may be passed in to the adaptor's constructor. Otherwise, normal copy or move construction is used for the container argument. The first template parameter T of the container adaptors shall denote the same type as Container::value_type.