for example boost::function
is moved almost entirely to std::function
, the same is with boost::shared_ptr
But I can't find std::any
?
Was it renamed or was not it placed in new standard at all by any reason?
Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work well with the C++ Standard Library. Boost libraries are intended to be widely useful, and usable across a broad spectrum of applications.
The boost::any class (based on the class of the same name described in "Valued Conversions" by Kevlin Henney, C++ Report 12(7), July/August 2000) is a variant value type based on the second category. It supports copying of any value type and safe checked extraction of that value strictly against its type.
C++11 includes new smart pointer classes: shared_ptr and the recently-added unique_ptr. Both are compatible with other Standard Library components, so you can safely store these smart pointers in standard containers and manipulate them with standard algorithms.
Container not only supports this model with C++11 but also backports it to C++03 via boost::container::allocator_traits including some C++17 changes. This class offers some workarounds for C++03 compilers to achieve the same allocator guarantees as std::allocator_traits .
Since the question was asked, we advanced towards std::experimental::any as an optional feature voted out of C++14 standard.
It was then implemented in GCC 5.1, at least.
The feature was since then standardized in C++17 resulting in std::any. See also C++17's std::variant for a type-safe union which either holds one of a limited known-types alternative, or is empty (thanks remy-lebeau for the tip).
Not every library from boost makes it into the standard (and even those that do may have components removed). Generally the commitee is pretty conservative when it comes to adding to the standardlibrary (since it's next to impossible to get something removed at a later point if the inclusion was a mistake (.e.g. because there is a better alternative)).
boost::function
and boost::shared_ptr
where pretty much a given for inclusion since they where already part of tr1
. boost::any
on the other hand did not make the cut. It might however be included in the standard library at a later point (e.g. in the next technical report, look here). While boost::any
is nice to have, I wouldn't rate it as quite as important as e.g. shared_ptr
.
Concluding: boost::any
is not part of C++11, since the committee didn't see any pressing need to include it
Std::any was recently accepted into the c++17 standard:
http://en.cppreference.com/w/cpp/utility/any
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With