This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.
stack::emplace() andqueue::emplace() should returndecltype(auto)Section: 23.6.3.1[queue.defn], 23.6.6.2[stack.defn]Status:C++20Submitter: Jonathan WakelyOpened: 2016-10-14Last modified: 2021-02-25
Priority:2
View all otherissues in [queue.defn].
View all issues withC++20 status.
Discussion:
Thestack andqueue adaptors are now defined as:
template <class... Args>reference emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }This breaks any code usingqueue<UserDefinedSequence> orstack<UserDefinedSequence> until the user-defined containers are updated to meet the new C++17 requirements.
decltype(auto) then we don't break any code. When used withstd::vector orstd::deque they will returnreference, as required, but when used with C++14-conforming containers they will returnvoid, as before.[2016-11-12, Issaquah]
Sat AM: P2
[2017-03-04, Kona]
Status to Tentatively Ready.
Proposed resolution:
This wording is relative to N4606.
Change return type ofemplace in class definition in 23.6.3.1[queue.defn]:
template <class... Args>referencedecltype(auto) emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }
Change return type ofemplace in class definition in 23.6.6.2[stack.defn]:
template <class... Args>referencedecltype(auto) emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }