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: Thu, 19 Oct 2023 18:46:31 +0200
On 19/10/2023 18:28, Sebastian Wittmeier via Std-Proposals wrote:
> The question is, whether this is too confusing or typical (or should
> be) for std library classes to show their size as implicit bool or
> implicit int.

Let's open Pandora's box, shall we?

  std::string s = "false";
  if (s) { ... }

Is `s` expected to be true or false here? Is std::string("123") == 123
true or false?

These operations don't make sense and should not be added.

-- 
Giuseppe D'Angelo

Received on 2023-10-19 16:46:35