+ 4
Differences between std::any and auto...
I recently came across the std::any class, recently introduced in C++17, based on boost::any. From the en.cppreference.com 's reference [ en.cppreference.com/w/cpp/utility/any ], I read that this class can 'hold an instance of any type'. What does that mean? Is it like C++11's auto which can deduce a type for a variable or better? Or is it something else? Kindly enlighten me on this.
3 Answers
+ 10
does this help? (the example code)
http://en.cppreference.com/w/cpp/utility/any/any_cast
+ 9
yep :) it is basically a copy of this:
https://theboostcpplibraries.com/boost.any
+ 2
I can see that one cannot use std::any without casting it to the required type with std::any_cast, but it really can hold anything, anytime. Thank you very much!