...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::intrusive::any_base_hook
// In header: <boost/intrusive/any_hook.hpp> template<class... Options> class any_base_hook { public: // construct/copy/destruct any_base_hook(); any_base_hook(const any_base_hook &); any_base_hook& operator=(const any_base_hook &); ~any_base_hook(); // public member functions bool is_linked() const; };
Derive a class from this hook in order to store objects of that class in an intrusive container.
The hook admits the following options: tag<>
, void_pointer<>
and link_mode<>
.
tag<>
defines a tag to identify the node. The same tag value can be used in different classes, but if a class is derived from more than one any_base_hook
, then each any_base_hook
needs its unique tag.
link_mode<>
will specify the linking mode of the hook (normal_link
, safe_link
).
void_pointer<>
is the pointer type that will be used internally in the hook and the the container configured to use this hook.
any_base_hook
public
construct/copy/destructany_base_hook();
Effects: If link_mode is or safe_link
initializes the node to an unlinked state.
Throws: Nothing.
any_base_hook(const any_base_hook &);
Effects: If link_mode is or safe_link
initializes the node to an unlinked state. The argument is ignored.
Throws: Nothing.
Rationale: Providing a copy-constructor makes classes using the hook STL-compliant without forcing the user to do some additional work. swap
can be used to emulate move-semantics.
any_base_hook& operator=(const any_base_hook &);
Effects: Empty function. The argument is ignored.
Throws: Nothing.
Rationale: Providing an assignment operator makes classes using the hook STL-compliant without forcing the user to do some additional work. swap
can be used to emulate move-semantics.
~any_base_hook();
Effects: If link_mode is normal_link
, the destructor does nothing (ie. no code is generated). If link_mode is safe_link
and the object is stored in a container an assertion is raised.
Throws: Nothing.