From b6f688321c11c99ba78ffe108ade2e92eec3f2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 7 Sep 2017 20:16:48 +0200 Subject: [PATCH] Fix outdated limitations in std containers. --- doc/intrusive.qbk | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index a83c203..1b197a3 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -144,9 +144,11 @@ A non-intrusive container has some limitations: a size overhead for each allocation to store bookkeeping information and a synchronization to protected concurrent allocation from different threads. -* Only copies of objects are stored in non-intrusive containers. Hence copy - or move constructors and copy or move assignment operators are required. Non-copyable - and non-movable objects can't be stored in non-intrusive containers. +* Before C++11, only copies of objects could be stored in non-intrusive containers. Still + copy or move constructors and copy or move assignment operators are required + and non-copyable and non-movable objects can't be stored in some containers. In any case, + [*new] objects have to be created inside the container using constructors and the same + object can't be shared between two containers. * It's not possible to store a derived object in a STL-container while retaining its original type. @@ -156,6 +158,9 @@ Intrusive containers have some important advantages: * Operating with intrusive containers doesn't invoke any memory management at all. The time and size overhead associated with dynamic memory can be minimized. +* The same object can be inserted in more than one container at the same time with + a tiny overhead in the object size. + * Iterating an Intrusive container needs less memory accesses than the semantically equivalent container of pointers: iteration is faster. @@ -208,7 +213,7 @@ Intrusive containers have also downsides: [[Memory management] [External] [Internal through allocator]] [[Insertion/Erasure time] [Faster] [Slower]] [[Memory locality] [Better] [Worse]] - [[Can hold non-copyable and non-movable objects by value] [Yes] [No]] + [[Can insert the same object in more than one container] [Yes] [No]] [[Exception guarantees] [Better] [Worse]] [[Computation of iterator from value] [Constant] [Non-constant]] [[Insertion/erasure predictability] [High] [Low]]