I do not think that it "breaks" it - boost::any not intended for the fact that you use it.
It is specially designed to work with type values (see the documents to which you already posted a link).
You must any_cast exactly indicate the type of any variable; under the hood, he checks the type. Clearly, const Base& does not match for Derived in this case.
std::shared_ptr< Base > provides / almost / what you think is needed. Or look here for more information.
source share