4.6.0
Freundlich's C++ toolkit
|
Intrusive list implementation.
An intrusive list is a list that does not actually own elements. Instead, when an element is constructed it gets the list it is going to be part of as a parameter. As long as the element is alive, it is part of the list. Such a list can be used to track elements whose lifetime is managed elsewhere. For example, fcppt.signal uses this technique to know which functions it has to call.
A type T
can be inserted into an fcppt::intrusive::list<T>
if it derives from fcppt::intrusive::base<T>
. The implementation of fcppt::intrusive::base owns a pair of pointers that represent a list node. When such an object is destroyed or moved from, it automatically unlinks itself from the list.
Here is an example: First, we declare the list type we are going to use:
Then, we define the element
type, deriving from the base class and adding a constructor that takes a list as an argument:
Here is a small example of how a list can be used:
Classes | |
class | fcppt::intrusive::base< Type > |
The base class of an element. More... | |
class | fcppt::intrusive::iterator< Type > |
The iterator type of an intrusive list. More... | |
class | fcppt::intrusive::list< Type > |
An intrusive list. More... | |