The std::any, introduced in C++17, will hold a single copy-constructible value of any type.
std::any can be treated as a type-safe alternative to void*, with the caveat (and benefit) that std::any provides value semantics.
Click to open in Compiler Explorer.
Leave a comment