C++ Logo


Advanced search

Subject: Re: The attribute nodiscard for the member function contains of associative containers.
From: Bo Persson (bo_at_[hidden])
Date: 2020-08-10 05:19:08

On 2020-08-10 at 11:22, Vladimir Grigoriev via Std-Discussion wrote:
> The member function empty of associative containers has the attribute
> nodiscard. It seems that the new member function contains should also
> have the attribute, should not it?

Maybe. Or maybe not.

The nodiscard on empty() is to help people that intended to call
clear(). Had the name been is_empty() this would have been less of a

So what is the risk of people accidentally calling contains() when they
intended insert()? Pretty small, IMO.

     Bo Persson

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups