C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Compact Initialization Syntax

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 08 Jun 2025 18:08:09 -0300
On Sunday, 8 June 2025 17:08:15 Brasilia Standard Time Smith, Jim via Std-
Proposals wrote:
> - Clarity of Intent: The use of {} makes it immediately clear that each
> variable is being initialized to a specific value, without the clutter of
> individual assignments.

Except in some circumstances we still need the (), where the {} has a different
meaning.

  std::vector<int> v1(10, 1);
  std::vector<int> v2{10, 1};

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering

Received on 2025-06-08 21:08:13