C++ Logo


Advanced search

Re: [std-proposals] Restrict what std::to_string may throw

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 8 Mar 2024 13:28:29 +0000
On Fri, 8 Mar 2024 at 13:15, Giuseppe D'Angelo via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> Il 08/03/24 14:04, Jan Schultke via Std-Proposals ha scritto:
> > I have a micro-proposal:
> >
> > https://eisenwave.github.io/cpp-proposals/to-string-throws.html
> >
> > Is it possible to go straight to LWG with this? I don't believe this
> > is editorial because it does change semantics. It's also not a defect
> > so seemingly not fit for a mere LWG issue. So I guess it needs to be a
> > proposal.
> Have you considered submitting a library defect?
> (Write to lwgchair_at_[hidden] , following the instructions here
> https://cplusplus.github.io/LWG/lwg-active.html )

He mentioned that it's not a defect, and I agree. Although I think if
the proposal was to just add a Throws element instead of changing to
"Effects: Equivalent to" I think it could be argued that failing to
restrict what it can throw is a defect.

I don't like the proposed change though, because using std::format
directly is a pretty bad implementation (it adds a ton of overhead
that isn't needed). As a specification for what it returns, it's fine.
But "Effects: Equivalent to..." is a much stronger implication than
just telling you what it returns.

If the proposal is to say "this won't throw unless allocation fails"
then just say that.

Received on 2024-03-08 13:29:47