[Bug libstdc++/77528] std::queue default constructor unnecessarily creates temporary of underlying Container
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 10 14:58:00 GMT 2017
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.
More information about the Gcc-bugs
mailing list