Please check out the library's documentation to learn more.
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)<h1>Boost PolyCollection library</h1> <p><a href="https://github.com/boostorg/poly_collection/tree/master"><img src="https://img.shields.io/badge/branch-master-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml"><img src="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml/badge.svg?branch=master" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/poly_collection"><img src="https://img.shields.io/drone/build/boostorg/poly_collection/master?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://ci.appveyor.com/project/joaquintides/poly-collection/branch/master"><img src="https://img.shields.io/appveyor/build/joaquintides/poly-collection/master?logo=appveyor&label=CI" alt="Build status" /></a> <a href="https://pdimov.github.io/boostdep-report/master/poly_collection.html"><img src="https://img.shields.io/badge/deps-master-brightgreen.svg" alt="Deps" /></a> <a href="https://www.boost.org/doc/libs/master/doc/html/poly_collection.html"><img src="https://img.shields.io/badge/docs-master-brightgreen.svg" alt="Documentation" /></a> <a href="https://regression.boost.org/master/developer/poly_collection.html"><img src="https://img.shields.io/badge/matrix-master-brightgreen.svg" alt="Enter the Matrix" /></a><br/> <a href="https://github.com/boostorg/poly_collection/tree/develop"><img src="https://img.shields.io/badge/branch-develop-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml"><img src="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml/badge.svg?branch=develop" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/poly_collection"><img src="https://img.shields.io/drone/build/boostorg/poly_collection/develop?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://ci.appveyor.com/project/joaquintides/poly-collection/branch/develop"><img src="https://img.shields.io/appveyor/build/joaquintides/poly-collection/develop?logo=appveyor&label=CI" alt="Build status" /></a> <a href="https://pdimov.github.io/boostdep-report/develop/poly_collection.html"><img src="https://img.shields.io/badge/deps-develop-brightgreen.svg" alt="Deps" /></a> <a href="https://www.boost.org/doc/libs/develop/doc/html/poly_collection.html"><img src="https://img.shields.io/badge/docs-develop-brightgreen.svg" alt="Documentation" /></a> <a href="https://regression.boost.org/develop/developer/poly_collection.html"><img src="https://img.shields.io/badge/matrix-develop-brightgreen.svg" alt="Enter the Matrix" /></a><br/> <a href="https://www.boost.org/users/license.html"><img src="https://img.shields.io/badge/license-BSL_1.0-blue.svg" alt="BSL 1.0" /></a> <img alt="C++11 required" src="https://img.shields.io/badge/standard-C%2b%2b11-blue.svg"> <img alt="Header-only library" src="https://img.shields.io/badge/build-header--only-blue.svg"></p> <p><strong>Boost.PolyCollection</strong>: fast containers of polymorphic objects.</p> <p>Typically, polymorphic objects cannot be stored <em>directly</em> 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 <a href="http://www.boost.org/doc/html/poly_collection/an_efficient_polymorphic_data_st.html">novel data structure</a> that is able to contiguously store polymorphic objects without such indirection, thus providing a value-semantics user interface and better performance. Four <em>polymorphic collections</em> are provided:</p> <ul> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_base_collection"><code>boost::base_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_function_collection"><code>boost::function_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_any_collection"><code>boost::any_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_variant_collection"><code>boost::variant_collection</code></a></li> </ul> <p>dealing respectively with classic base/derived or OOP polymorphism, function wrapping in the spirit of <code>std::function</code>, so-called <a href="https://en.wikipedia.org/wiki/Duck_typing"><em>duck typing</em></a> as implemented by <a href="http://www.boost.org/libs/type_erasure">Boost.TypeErasure</a>, and variant-like <em>closed polymorphism</em>.</p> <h2>Learn about Boost.PolyCollection</h2> <ul> <li><a href="http://boost.org/libs/poly_collection">Online docs</a></li> <li><a href="http://bannalia.blogspot.com/2014/05/fast-polymorphic-collections.html">Seminal article at bannalia.blogspot.com</a></li> </ul> <h2>Install Boost.PolyCollection</h2> <ul> <li><a href="https://www.boost.org/users/download/">Download Boost</a> and you're ready to go (this is a header-only library requiring no building).</li> <li>Using Conan 2: In case you don't have it yet, add an entry for Boost in your <code>conanfile.txt</code> (the example requires at least Boost 1.86):</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">[requires] boost/[>=1.86.0] </code></pre> <ul>If you're not using any compiled Boost library, the following will skip building altogether:</ul> <pre class="highlightjs highlight"><code class="language- hljs">[options] boost:header_only=True </code></pre> <ul> <li>Using vcpkg: Execute the command</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">vcpkg install boost-poly-collection </code></pre> <ul> <li>Using CMake: <a href="https://github.com/boostorg/cmake">Boost CMake support infrastructure</a> allows you to use CMake directly to download, build and consume all of Boost or some specific libraries.</li> </ul> <h2>Support</h2> <ul> <li>Join the <strong>#boost</strong> discussion group at <a href="https://cpplang.slack.com/">cpplang.slack.com</a> (<a href="https://cppalliance.org/slack/">ask for an invite</a> if you’re not a member of this workspace yet)</li> <li>Ask in the <a href="https://lists.boost.org/mailman/listinfo.cgi/boost-users">Boost Users mailing list</a> (add the <code>[poly_collection]</code> tag at the beginning of the subject line)</li> <li><a href="https://github.com/boostorg/poly_collection/issues">File an issue</a></li> </ul> <h2>Contribute</h2> <ul> <li><a href="https://github.com/boostorg/poly_collection/pulls">Pull requests</a> against <strong>develop</strong> branch are most welcome. Note that by submitting patches you agree to license your modifications under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</li> </ul>
<h1>Boost PolyCollection library</h1> <p><a href="https://github.com/boostorg/poly_collection/tree/master"><img src="https://img.shields.io/badge/branch-master-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml"><img src="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml/badge.svg?branch=master" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/poly_collection"><img src="https://img.shields.io/drone/build/boostorg/poly_collection/master?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://ci.appveyor.com/project/joaquintides/poly-collection/branch/master"><img src="https://img.shields.io/appveyor/build/joaquintides/poly-collection/master?logo=appveyor&label=CI" alt="Build status" /></a> <a href="https://pdimov.github.io/boostdep-report/master/poly_collection.html"><img src="https://img.shields.io/badge/deps-master-brightgreen.svg" alt="Deps" /></a> <a href="https://www.boost.org/doc/libs/master/doc/html/poly_collection.html"><img src="https://img.shields.io/badge/docs-master-brightgreen.svg" alt="Documentation" /></a> <a href="https://regression.boost.org/master/developer/poly_collection.html"><img src="https://img.shields.io/badge/matrix-master-brightgreen.svg" alt="Enter the Matrix" /></a><br/> <a href="https://github.com/boostorg/poly_collection/tree/develop"><img src="https://img.shields.io/badge/branch-develop-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml"><img src="https://github.com/boostorg/poly_collection/actions/workflows/ci.yml/badge.svg?branch=develop" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/poly_collection"><img src="https://img.shields.io/drone/build/boostorg/poly_collection/develop?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://ci.appveyor.com/project/joaquintides/poly-collection/branch/develop"><img src="https://img.shields.io/appveyor/build/joaquintides/poly-collection/develop?logo=appveyor&label=CI" alt="Build status" /></a> <a href="https://pdimov.github.io/boostdep-report/develop/poly_collection.html"><img src="https://img.shields.io/badge/deps-develop-brightgreen.svg" alt="Deps" /></a> <a href="https://www.boost.org/doc/libs/develop/doc/html/poly_collection.html"><img src="https://img.shields.io/badge/docs-develop-brightgreen.svg" alt="Documentation" /></a> <a href="https://regression.boost.org/develop/developer/poly_collection.html"><img src="https://img.shields.io/badge/matrix-develop-brightgreen.svg" alt="Enter the Matrix" /></a><br/> <a href="https://www.boost.org/users/license.html"><img src="https://img.shields.io/badge/license-BSL_1.0-blue.svg" alt="BSL 1.0" /></a> <img alt="C++11 required" src="https://img.shields.io/badge/standard-C%2b%2b11-blue.svg"> <img alt="Header-only library" src="https://img.shields.io/badge/build-header--only-blue.svg"></p> <p><strong>Boost.PolyCollection</strong>: fast containers of polymorphic objects.</p> <p>Typically, polymorphic objects cannot be stored <em>directly</em> 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 <a href="http://www.boost.org/doc/html/poly_collection/an_efficient_polymorphic_data_st.html">novel data structure</a> that is able to contiguously store polymorphic objects without such indirection, thus providing a value-semantics user interface and better performance. Four <em>polymorphic collections</em> are provided:</p> <ul> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_base_collection"><code>boost::base_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_function_collection"><code>boost::function_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_any_collection"><code>boost::any_collection</code></a></li> <li><a href="http://www.boost.org/doc/html/poly_collection/tutorial.html#poly_collection.tutorial.basics.boost_variant_collection"><code>boost::variant_collection</code></a></li> </ul> <p>dealing respectively with classic base/derived or OOP polymorphism, function wrapping in the spirit of <code>std::function</code>, so-called <a href="https://en.wikipedia.org/wiki/Duck_typing"><em>duck typing</em></a> as implemented by <a href="http://www.boost.org/libs/type_erasure">Boost.TypeErasure</a>, and variant-like <em>closed polymorphism</em>.</p> <h2>Learn about Boost.PolyCollection</h2> <ul> <li><a href="http://boost.org/libs/poly_collection">Online docs</a></li> <li><a href="http://bannalia.blogspot.com/2014/05/fast-polymorphic-collections.html">Seminal article at bannalia.blogspot.com</a></li> </ul> <h2>Install Boost.PolyCollection</h2> <ul> <li><a href="https://www.boost.org/users/download/">Download Boost</a> and you're ready to go (this is a header-only library requiring no building).</li> <li>Using Conan 2: In case you don't have it yet, add an entry for Boost in your <code>conanfile.txt</code> (the example requires at least Boost 1.86):</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">[requires] boost/[>=1.86.0] </code></pre> <ul>If you're not using any compiled Boost library, the following will skip building altogether:</ul> <pre class="highlightjs highlight"><code class="language- hljs">[options] boost:header_only=True </code></pre> <ul> <li>Using vcpkg: Execute the command</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">vcpkg install boost-poly-collection </code></pre> <ul> <li>Using CMake: <a href="https://github.com/boostorg/cmake">Boost CMake support infrastructure</a> allows you to use CMake directly to download, build and consume all of Boost or some specific libraries.</li> </ul> <h2>Support</h2> <ul> <li>Join the <strong>#boost</strong> discussion group at <a href="https://cpplang.slack.com/">cpplang.slack.com</a> (<a href="https://cppalliance.org/slack/">ask for an invite</a> if you’re not a member of this workspace yet)</li> <li>Ask in the <a href="https://lists.boost.org/mailman/listinfo.cgi/boost-users">Boost Users mailing list</a> (add the <code>[poly_collection]</code> tag at the beginning of the subject line)</li> <li><a href="https://github.com/boostorg/poly_collection/issues">File an issue</a></li> </ul> <h2>Contribute</h2> <ul> <li><a href="https://github.com/boostorg/poly_collection/pulls">Pull requests</a> against <strong>develop</strong> branch are most welcome. Note that by submitting patches you agree to license your modifications under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</li> </ul>