C++ Logo

std-proposals

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 2 Nov 2023 18:39:20 +0200
On Thu, 2 Nov 2023 at 18:33, Edward Catmur <ecatmur_at_[hidden]> wrote:

> And we do, which is fine for empty(), but to have a contextual conversion to bool that is always true (or false, for a 0-sized array) would be a source of confusion and frustration. Arthur's mentioned std::optional<bool> and likewise std::array<bool, N> might be expected to evaluate all() or, possibly, any() for contextual conversion to bool.

Alright then. Them's who want this functionality will need to wrap
their types. That tends to be the answer to all of life, universe, and
everything anyway,
not 42.

Received on 2023-11-02 16:39:33