Class template recursive_wrapper
boost::recursive_wrapper — Solves circular dependencies, enabling recursive types.
Synopsis
template<typename T> class recursive_wrapper { public: // types typedef T type; // construct/copy/destruct recursive_wrapper(); recursive_wrapper(const recursive_wrapper &); recursive_wrapper(const T &); ~recursive_wrapper(); // modifiers void swap(recursive_wrapper &); recursive_wrapper & operator=(const recursive_wrapper &); recursive_wrapper & operator=(const T &); // queries T & get(); const T & get() const; T * get_pointer(); const T * get_pointer() const; };
Description
The recursive_wrapper class template has an
interface similar to a simple value container, but its content is
allocated dynamically. This allows recursive_wrapper to
hold types T whose member data leads to a circular
dependency (e.g., a data member of T has a data member
of type T).
The application of recursive_wrapper is easiest
understood in context. See
the section called “Recursive types with recursive_wrapper” for a
demonstration of a common use of the class template.
Notes:
- Any type specified as the template argument to
recursive_wrappermust be capable of construction viaoperator new. Thus, for instance, references are not supported.
recursive_wrapper construct/copy/destruct
-
recursive_wrapper();
Initializes
*thisby default construction ofT.Requires: Tmust fulfill the requirements of the DefaultConstructible [20.1.4] concept.Throws: May fail with any exceptions arising from the default constructor of Tor, in the event of insufficient memory, withstd::bad_alloc. -
recursive_wrapper(const recursive_wrapper & other);
Copies the content of
otherinto*this.Throws: May fail with any exceptions arising from the copy constructor of Tor, in the event of insufficient memory, withstd::bad_alloc. -
recursive_wrapper(const T & operand);
Copies
operandinto*this.Throws: May fail with any exceptions arising from the copy constructor of Tor, in the event of insufficient memory, withstd::bad_alloc. -
~recursive_wrapper();
Deletes the content of
*this.Throws: Will not throw.
recursive_wrapper modifiers
-
void swap(recursive_wrapper & other);
Exchanges contents of
*thisandother.Throws: Will not throw. -
recursive_wrapper & operator=(const recursive_wrapper & rhs);
Assigns the content of
rhsto the content of*this.Requires: Tmust fulfill the requirements of the Assignable concept.Throws: May fail with any exceptions arising from the assignment operator of T. -
recursive_wrapper & operator=(const T & rhs);
Assigns
rhsinto the content of*this.Requires: Tmust fulfill the requirements of the Assignable concept.Throws: May fail with any exceptions arising from the assignment operator of T.
| Copyright © 2002, 2003 Eric Friedman, Itay Maman |
