You can still distinguish that in a single pointer's worth of memory. Since dynamic allocation with alignment is required, you can use one of the alignment bits as a tag for "holds moved-from indirect". It looks like C++29 is getting constexpr support for that trick too.
I have a constexpr implementation of niche/tombstone optimization that works with clang -std=c++26, but of course it might very well depend on some compiler specific behavior...
Hm for this specific case I think you may be right. The pointer tagging I was referring to is usually for when you also want to still access the live object at the same time as using the alignment bits for additional data, which I suppose isn't needed here.
View all comments
Show parent comment
6
u/LB-- Professional+Hobbyist Aug 14 '26
You can still distinguish that in a single pointer's worth of memory. Since dynamic allocation with alignment is required, you can use one of the alignment bits as a tag for "holds moved-from indirect". It looks like C++29 is getting constexpr support for that trick too.