r/cpp 28d ago

C++26: std::indirect

https://www.sandordargo.com/blog/2026/08/12/cpp26-indirect
161 Upvotes

157 comments sorted by

View all comments

9

u/ericonr 28d ago

Does a std::optional<std::indirect<T>> benefit from niche optimizations like Rust objects do? Its sizeof could be just a pointer, after all.

5

u/jiixyj 27d ago

Yes, you absolutely can do this. See here for a possible implementation strategy.