C++ Logo

std-proposals

Advanced search

Re: Request for opinion: Leaning on strong typing in STL.

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 22 Jul 2020 20:16:43 -0700
On Wednesday, 22 July 2020 17:20:36 PDT Arthur O'Dwyer via Std-Proposals
wrote:
> Presumably Scott's proposed `vector(reservation_t)` constructor would be
> marked `explicit`, to turn off that implicit conversion. Implicit
> conversions are the devil.

Sorry, I didn't mean that the implicit was the issue. My argument is that a
reserved but empty vector is has no purpose as a function argument.

        func(vector<T>(reservation_t(12)));

I could see use for this as an NSDMI, but what if I want to reserve and add
one element? We need a (rough) rule on what makes sense to have a constructor
for.
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2020-07-22 22:20:09