1 //-----------------------------------------------------------------------------
2 // boost variant/recursive_wrapper.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2002-2003
7 // Eric Friedman, Itay Maman
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
14 #define BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
16 #include "boost/variant/recursive_wrapper_fwd.hpp"
17 #include "boost/checked_delete.hpp"
21 //////////////////////////////////////////////////////////////////////////
22 // class template recursive_wrapper
24 // See docs and recursive_wrapper_fwd.hpp for more information.
28 class recursive_wrapper
34 private: // representation
43 recursive_wrapper(const recursive_wrapper& operand);
44 recursive_wrapper(const T& operand);
46 private: // helpers, for modifiers (below)
48 void assign(const T& rhs);
52 recursive_wrapper& operator=(const recursive_wrapper& rhs)
58 recursive_wrapper& operator=(const T& rhs)
64 void swap(recursive_wrapper& operand)
73 T& get() { return *get_pointer(); }
74 const T& get() const { return *get_pointer(); }
76 T* get_pointer() { return p_; }
77 const T* get_pointer() const { return p_; }
82 recursive_wrapper<T>::~recursive_wrapper()
84 boost::checked_delete(p_);
88 recursive_wrapper<T>::recursive_wrapper()
94 recursive_wrapper<T>::recursive_wrapper(const recursive_wrapper& operand)
95 : p_(new T( operand.get() ))
100 recursive_wrapper<T>::recursive_wrapper(const T& operand)
105 template <typename T>
106 void recursive_wrapper<T>::assign(const T& rhs)
111 // function template swap
113 // Swaps two recursive_wrapper<T> objects of the same type T.
115 template <typename T>
116 inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs)
123 #endif // BOOST_VARIANT_RECURSIVE_WRAPPER_HPP