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 11:01:41 -0700
On Wednesday, 22 July 2020 10:50:52 PDT Scott Michaud via Std-Proposals wrote:
> Any thoughts on where else this could be used?

Call the explicit vec.reserve() function instead. There's no ambiguity in what
it does.

I don't think we need more short-hands. Constructors should be reserved for
the few needs where multiple lines would not do. Here's a litmus test: does it
make sense to pass an object created with *just* that constructor to a
function, either by value or by const-reference?

func({1, 2, 3}); // certainly does
func(reservation_t{12}); // ???

This is not an absolute rule, of course. But it serves as a good indicator.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2020-07-22 13:05:03