4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * A pointer with copy-on-write semantics
11 * The original version of this class was written by Yonat Sharon
12 * and is freely available at http://ootips.org/yonat/
14 * I modified it to use boost::shared_ptr internally, rather than use his
15 * home-grown equivalent.
21 #include <boost/shared_ptr.hpp>
30 explicit cow_ptr(T * = 0);
31 cow_ptr(cow_ptr const &);
32 cow_ptr & operator=(cow_ptr const &);
34 T const & operator*() const;
35 T const * operator->() const;
36 T const * get() const;
43 boost::shared_ptr<T> ptr_;
49 cow_ptr<T>::cow_ptr(T * p)
55 cow_ptr<T>::cow_ptr(cow_ptr const & other)
61 cow_ptr<T> & cow_ptr<T>::operator=(cow_ptr const & other)
70 T const & cow_ptr<T>::operator*() const
77 T const * cow_ptr<T>::operator->() const
84 T const * cow_ptr<T>::get() const
91 T & cow_ptr<T>::operator*()
99 T * cow_ptr<T>::operator->()
106 template <typename T>
107 T * cow_ptr<T>::get()
114 template <typename T>
115 void cow_ptr<T>::copy()
118 ptr_ = boost::shared_ptr<T>(new T(*ptr_.get()));
121 } // namespace support
124 #endif // NOT COW_PTR_H