This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/77528] std::queue default constructor unnecessarily creates temporary of underlying Container
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Jan 2017 14:58:10 +0000
- Subject: [Bug libstdc++/77528] std::queue default constructor unnecessarily creates temporary of underlying Container
- Auto-submitted: auto-generated
- References: <bug-77528-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77528
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to jerryct from comment #4)
> Thus a constructor like libcxx has:
> _LIBCPP_INLINE_VISIBILITY
> stack()
> _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
> : c() {}
>
> would solve two problems:
> - reduce the number of allocations
> - make container adapaters usable for rather big containers.
That introduces a different problem though. This won't compile with libc++:
#include <stack>
struct D : std::deque<int> { D(int) { } };
template class std::stack<int, D>;
That compiles fine with libstdc++ and we want to preserve that property.