https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86127

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As I said in comment 6, I've already removed the copies that forward_list does
on destruction.

As I said in comment 3, there are no copies in the default constructor, they're
in the initializer-list constructors. The standard says the initializer-list
constructors look like:

  vector(initializer_list<T>, const Allocator& = Allocator());

That default argument needs to get copied into the vector's allocator member
somehow.

It could be avoided by defining:

  vector(initializer_list<T>);
  vector(initializer_list<T>, const Allocator&);

But doing so just to avoid making copies of a cheap-to-copy object is not a
good justification, and would make it impossible to explicitly instantiate the
container with a non-default constructible allocator type.

Node-based containers such as forward_list and map neede to convert the
allocator from the value_type to the node type. That can either happen once on
construction, or every time elements are inserted or erased. Doing it on
construction is the obvious choice, and that's where you see the "template copy
constructor" lines for forward_list and map.

The standard allows those copies, and they should be cheap. There is no bug
here.

Reply via email to