To hold arbitrarily large objects, boost::any / std::any surely needs to allocate heap space for objects. However, for small types whose size is less or equal to a pointer (int,char,bool,...), any could instead store the value in-place in the pointer slot or in some other in-place memory and not allocate heap space. But does the implementation do this?
I have a scenario where I often store small types in an any and only sometimes larger types like strings. The code is quite hot and therefore I am asking the question. If the optimization is not performed, I might be better off with an own implementation that stores small types in-place.