C++ Logo

std-proposals

Advanced search

Re: [std-proposals] null reference

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Thu, 4 Apr 2024 01:47:06 +0200
Or as alternative return a non-owning pointer. References are non-null by definition. -----Ursprüngliche Nachricht----- Von:Henry Miller via Std-Proposals <std-proposals_at_[hidden]> Betreff:Re: [std-proposals] null reference you want the container to return a std::optional not a null reference. the nice thing about a reference is in practice nobody writes code to make them null even though it is easy and works as expected in most cases (i have done it to prove a point. No I won't share more, the conclusion is don't do that) throwing an exception is sometimes a useful alternative, as is the std::expected variant of exceptions. Optional is likely what you want, and it is much less confusing.

Received on 2024-04-03 23:47:08