This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/77528] std::queue default constructor unnecessarily creates temporary of underlying Container


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]