C++ Logo

std-discussion

Advanced search

Re: Throwing noncopyable temporaries

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Fri, 2 Sep 2022 12:39:21 +0200
On 02/09/2022 10.32, Lénárd Szolnoki via Std-Discussion wrote:
> From the wording it's not clear to me if it's the throw expression and/or the handler should be ill-formed.

The wording is in [except.throw], thus we're talking about the throw-expression,
not the handler.

> As throw is an expression, it can be used in SFINAE context too. IMO this should work, but it doesn't:
>
> template <typename T>
> concept throwable = requires(T (*fptr)()) {
> throw fptr();
> };

Yes, that looks fine.

> Probably throw and catch should be ill-formed at the same time.

It would certainly be feasible to extend [except.handle] to make
a handler ill-formed that would require the use of a deleted
or inaccessible copy constructor.

Jens

Received on 2022-09-02 10:39:25