Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Class template any_base_hook

boost::intrusive::any_base_hook

Synopsis

// In header: <boost/intrusive/any_hook.hpp>

template<class... Options> 
class any_base_hook : public make_any_base_hook::type< O1, O2, O3 > {
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;
};

Description

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/destruct

  1. any_base_hook();

    Effects: If link_mode is or safe_link initializes the node to an unlinked state.

    Throws: Nothing.

  2. 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.

  3. 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.

  4. ~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.

any_base_hook public member functions

  1. bool is_linked() const;

    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


PrevUpHomeNext