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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Patrick Palka from comment #1)
> > We might first need to implement P2231 (for constexpr optional) before this
> > function can be properly constexpr.
> 
> Implemented in r12-4389

Yay, thanks!  I thought this would be enough to straightforwardly make
emplace-deref constexpr, but I ran into an unrelated wrinkle.  During constexpr
evaluation we can't use placement new to initialize the contained value
directly from *__i and instead have to use the equivalent of
construct_at(&value, *__i), but the latter incurs an extra move due to the
temporary materialization of *__i, which is contrary to the effects of
emplace-deref ([range.nonprop.cache]/1.6):

  Calls reset().  Then initializes the contained value as if
direct-non-list-initializing an object of type T with the argument *i.

Am I missing something or is it not possible to perform this direct-init in the
constexpr case?

Reply via email to