Copyright © 2016, 2017 Joaquín M López Muñoz
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents
Dynamic polymorphism in C++ requires that objects (such as instances of classes derived from an abstract base) be accessed through an indirection pointer because their actual type and size are not known at the point of usage. As a consequence, regular containers cannot store polymorphic objects directly: the usual workaround is to have containers of pointers to heap-allocated elements. In modern computer architectures this pattern incurs in two types of inefficiency:
When the particular traversal order is not relevant to the user application, Boost.PolyCollection proposes an alternative data structure that restores memory contiguity and packs elements according to their concrete type. Three container class templates are provided:
respectively dealing with three different types of dynamic polymorphism available in C++:
The interface of these containers closely follows that of standard containers.
Additionally, the library provides versions of many of the standard library
with improved performance and a special feature called type restitution
that allows user code to provide clues on the concrete types of the elements
stored for further opportunities of increased efficiency related to inlining
Boost.PolyCollection is a header-only library. C++11 support is required. The library has been verified to work with Visual Studio 2015, GCC 5.2 and Clang 3.7.
Last revised: August 19, 2017 at 16:57:06 GMT