[Bug libstdc++/102567] Missing noexcept specialization of std::function

fw at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 2 20:51:23 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102567

--- Comment #3 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> This is not a libstdc++ bug, we implement what the standard says.
> 
> Maybe it used to compile, but it was meaningless. You could say it was a
> function of void() noexcept, but you could still store a target function
> that throwed, and its operator() could still throw.

Sure, but in my code, I did not do this. The call operator was invoked in a
noexcept context, and the type was expected to match (but of course the
compiler did not check this).

> Both std::move_only_function (P0288) and std::function_ref (P0792) support
> using a function type that is optionally const-qualified and optionally
> noexcept, and it actually means something (it affects what you can store in
> there, and whether they can modify a stateful target object, and whether
> their operator() is noexcept or not). std::function is not going to get
> updated though.

Neither paper seems to cover a polymorphic function type that takes ownership,
though, so I don't quite see how these replace std::function.

Or is std::function semi-deprecated because it poorly matches
capture-by-reference in lambdas?


More information about the Gcc-bugs mailing list