Home | Libraries | People | FAQ | More |
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
"boost/poly_collection/exception.hpp"
synopsis"boost/poly_collection/base_collection_fwd.hpp"
synopsis"boost/poly_collection/base_collection.hpp"
synopsis"boost/poly_collection/function_collection_fwd.hpp"
synopsis"boost/poly_collection/function_collection.hpp"
synopsis"boost/poly_collection/any_collection_fwd.hpp"
synopsis"boost/poly_collection/any_collection.hpp"
synopsis"boost/poly_collection/algorithm.hpp"
synopsisWarning | |
---|---|
Boost.PolyCollection has been accepted into Boost but it is yet to be released as part of an official Boost distribution. |
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:
boost::base_collection
boost::function_collection
boost::any_collection
respectively dealing with three different types of dynamic polymorphism available in C++:
std::function
.
The interface of these containers closely follows that of standard containers.
Additionally, the library provides versions of many of the standard library
algorithms (including std::for_each
)
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
and devirtualization.
Note | |
---|---|
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: June 27, 2017 at 21:03:16 GMT |