C++ Logo

std-proposals

Advanced search

Re: [std-proposals] copy constructor of std::vector

From: Federico Kircheis <federico_at_[hidden]>
Date: Tue, 13 Jun 2023 20:28:54 +0200
On 13/06/2023 19.49, Thiago Macieira via Std-Proposals wrote:
> On Tuesday, 13 June 2023 10:31:36 PDT Federico Kircheis via Std-Proposals
> wrote:
>> Is there no situation where we can talk only about types where we know
>> if those are not copyable? (I fear I know the answer)
>>
>> For example std::vector<std::unique_ptr<T>>, no matter what T is.
>
> template <typename _Tp, typename _Dp = default_delete<_Tp>>
> class unique_ptr;
>
> You can't write that for a standard library type, but libraries can for their
> own types. Are you going to add a rule to the standard that only applies to
> std::unique_ptr? Might as well partially specialise std::vector for
> std::unique_ptr<T> and the last time we did that we ended up with
> std::vector<bool>.
>

Yes... I see no way forward either, cannot say I am happy with that :(

I am not sure that specializing vector<obviously-non-copyable> over
other types is the same as vector of bool. (have probably not given too
much thought)

While it is true that is makes a difference for some traits, it is not a
behavioral difference, as in both cases the vector cannot be copied.

Received on 2023-06-13 18:28:58