This is a implementation of N4562. Drop-in replacement for std::any (C++17).
It contains configurable small object optimization.
By default storing objects with a size of up to 3 words (such as int
, float
, std::shared_ptr
, std::string
) in the container will not trigger a dynamic allocation.
For a easy to understand documentation, see cppreference, except our namespace is nonstd
.
You may additionally define the following preprocessor symbols (making the implementation non-standard):
ANY_IMPL_NO_EXCEPTIONS
: This disables code paths that throw exceptions.ANY_IMPL_NO_RTTI
: This disablesany::type()
, thus removing all code paths using RTTI.