C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bool casting operator to check if a container not empty

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Wed, 1 Nov 2023 20:09:07 +0100
On 01/11/2023 02:45, Hewill Kang via Std-Proposals wrote:
> Ranges adaptors *do* provide (explicit) operator bool since they all
> derived from ‘view_interface’.

With this precedent, for better or worse, I'd say that the decision has
already been taken, and operator bool() should be added to all
containers. It makes very little sense that

  if (vector)

doesn't compile, but

  if (views::all(vector))

does.

My 2 c,
-- 
Giuseppe D'Angelo

Received on 2023-11-01 19:09:11