You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Effects: Constructs a vector equal to the range [first, last), using the specified allocator.
Complexity: Makes only N calls to the copy constructor of T (where N is the distance between first and last) and no reallocations if iterators first and last are of forward, bidirectional, or random access categories. It makes order N calls to the copy constructor of T and order logN reallocations if they are just input iterators.
But T does not need to be copy constructible.
The text was updated successfully, but these errors were encountered:
It does need to be copy constructible (Edit: oops, I was thinking of the vector(size_type, const T&) constructor for some reason, not the one clearly shown above!), the point is that copy construction might not use a copy constructor. Some other constructor could be chosen, or it might have no constructors at all, e.g. scalars.
gonzalobg
changed the title
[vector.cons.10] complexity in term of copy constructor calls but T does not need to be copy constructible
[vector.cons.10] complexity in term of copy constructor calls but T does not need to have constructors
Dec 13, 2023
The proper requirement is that T must be Cpp17EmplaceConstructible from iter_reference_t<InputIterator> (https://godbolt.org/z/Wj3Y9xzx1) as stated in [sequence.reqmts]/8. (Yes, [sequence.reqmts]/2.5's requirement that "i and j ... refer to elements implicitly convertible to value_type" is an extraneous "sanity check".)
Maybe the complexity requirement should state that exactly N objects of type T are initialized?
https://eel.is/c++draft/vector#cons-10 states:
But
T
does not need to be copy constructible.The text was updated successfully, but these errors were encountered: