Unconstrained Dynamic Types using Void Pointers and std::any

Learn how to use void pointers and std::any to implement unconstrained dynamic types, and understand when they should be used

Ryan McCombe
Updated
Hello! I'm here to help you with any questions about this lesson. Feel free to ask me anything - whether it's about specific concepts, examples, or how to apply what you've learned!

Questions & Answers

Answers are generated by AI models and may not have been reviewed. Be mindful when running any code on your device.

When to Use Dynamic Types in C++
The lesson mentions dynamic typing should be rare in C++. When is it appropriate to use void pointers or std::any?
std::any vs std::variant
What's the difference between std::any and std::variant? When would I use one over the other?
Performance Impact of std::any
Does using std::any have a significant performance impact compared to using concrete types directly?
Storing std::any in a Container
How can I store std::any objects in a container like std::vector?
std::any and Memory Leaks
Can using std::any lead to memory leaks? How can I prevent them?
std::any and Small Object Optimization
Does std::any use small object optimization? If so, how does it work and what are the benefits?