[Bug libstdc++/124121] Missed optimization in initialization of std::inplace_vector with std::initializer_list
tkaminsk at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 19 14:39:13 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
--- Comment #12 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
Instead of zeroing whole array at runtime for trivially default contractible
and destructible type we can just do:
```
_M_elems[0] = _Tp();
_M_elems[0].~_Tp();
```
This have constant cost regardless of capacity. The only meaningful case is if
the _Tp itself is large.
More information about the Gcc-bugs
mailing list