Boost.PolyCollection: fast containers of polymorphic objects.
Typically, polymorphic objects cannot be stored directly in regular containers and need be accessed through an indirection pointer, which introduces performance problems related to CPU caching and branch prediction. Boost.PolyCollection implements a novel data structure that is able to contiguously store polymorphic objects without such indirection, thus providing a value-semantics user interface and better performance. Four polymorphic collections are provided:
dealing respectively with classic base/derived or OOP polymorphism, function wrapping
in the spirit of std::function, so-called
duck typing as implemented by
Boost.TypeErasure,
and variant-like closed polymorphism.
conanfile.txt (the example requires at least Boost 1.86):[requires]
boost/[>=1.86.0]
[options]
boost:header_only=True
vcpkg install boost-poly-collection
[poly_collection] tag at the beginning of the subject line)