...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_member_hook
// In header: <boost/intrusive/any_hook.hpp> template<class ... Options> class any_member_hook : public make_any_member_hook::type { public: // public member functions any_member_hook() noexcept; any_member_hook(const any_member_hook &) noexcept; any_member_hook & operator=(const any_member_hook &) noexcept; ~any_member_hook(); bool is_linked() const noexcept; };
Store this hook in a class to be inserted in an intrusive container.
The hook admits the following options: void_pointer<>
and link_mode<>
.
link_mode<>
will specify the linking mode of the hook (normal_link
or safe_link
).
void_pointer<>
is the pointer type that will be used internally in the hook and the container configured to use this hook.
any_member_hook
public member functionsany_member_hook() noexcept;
Effects: If link_mode is or safe_link
initializes the node to an unlinked state.
Throws: Nothing.
any_member_hook(const any_member_hook &) noexcept;
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_member_hook & operator=(const any_member_hook &) noexcept;
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_member_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.
bool is_linked() const noexcept;
Precondition: link_mode must be safe_link
.
Returns: true, if the node belongs to a container, false otherwise. This function can be used to test whether container::iterator_to
will return a valid iterator.
Complexity: Constant