C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::ranges::equal(v, {1,2,3,4,5})

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Wed, 25 Jan 2023 13:15:44 +0100
Il 25/01/23 05:44, Jason McKesson via Std-Proposals ha scritto:
> Unfortunately, that clear, reasonable design is being replaced, bit by
> bit. They're now becoming an expedient way to make small lists of
> numbers as if they were literals. Of course, the fact that
> braced-init-lists*still* are not expressions keeps forcing these
> `initializer_list` hack-fixes onto things instead of finally sitting
> down and deciding what exactly this grammatical construct ought to be
> used for.

Sure, I should not have used "datatype".

The point is that at the moment they're a grammar construct that does
some things. But it has also cannibalized a very convenient syntax;
people will always push for having a convenient syntax over some overly
stringent semantic requirements (as much as these requirements make
sense in the broader context of the C++ language design). That's my
motivation behind P2248 (I want to be able to write
`find(vector_of_points, {1,2}`), and I guess the motivation behind
similar proposals (Arthur's idea, P2218, possibly more...).

I'm not sure how to solve the conundrum here; in the past some people
entertained the idea of "user-defined brace list literals", which would
still be not as convenient as writing {1,2,3} when one needs a list but
maybe not very far off. That will solve the problem... in a few years.
Today, even something as simple as
   template <class T, size_t N> using L = std::array<T,N>;
and then writing `L{1,2,3}` still requires C++20 (!).

My 2 c,
-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2023-01-25 12:15:47