Forward declaration and std::future

Evgen Bodunov evgen@globus.software
Mon Sep 13 08:32:59 GMT 2021


> On 12.09.2021, at 22:04, Jonathan Wakely via Libstdc++ <libstdc++@gcc.gnu.org> wrote:
> 
> On Sun, 12 Sep 2021, 19:30 Evgen Bodunov, <evgen@globus.software> wrote:
>> 
>> Please, could you refer exact part and version of the standard?
>> 
> 
> Please reply to the mailing list, not just to me.
> 
> Every version of the standard has the same requirement, see
> http://eel.is/c++draft/requirements#res.on.functions-2.5
> 
> std::promise requires its result type to be destructible. We are allowed to
> assert that by using is_destructible because we can assume the type is
> complete, because [res.on.functions] says it must be.
> 
> In a correct program, the assertion will not fail.

Thank you for the detailed response. For some reason I expected that if there is not enough 
type data to compile the code correctly, there would be an error from the compiler, not from 
static_assert. As for example in case of inheritance or creating objects from a type that was 
forward declared. And in this case there is an error saying that the class doesn't have a 
destructor, although it actually exists and this is confusing.



More information about the Libstdc++ mailing list