File indexing completed on 2025-01-18 09:30:26
0001
0002 #ifndef BOOST_CONTRACT_DETAIL_AUTO_PTR_HPP_
0003 #define BOOST_CONTRACT_DETAIL_AUTO_PTR_HPP_
0004
0005
0006
0007
0008
0009
0010 #include <boost/contract/detail/operator_safe_bool.hpp>
0011 #include <boost/contract/detail/debug.hpp>
0012 #include <boost/config.hpp>
0013
0014 namespace boost { namespace contract { namespace detail {
0015
0016
0017
0018 template<typename T>
0019 class auto_ptr {
0020 public:
0021 explicit auto_ptr(T* ptr = 0) : ptr_(ptr) {}
0022
0023 ~auto_ptr() BOOST_NOEXCEPT_IF(false) { delete ptr_; }
0024
0025 T* release() {
0026 T* ptr = ptr_;
0027 ptr_ = 0;
0028 return ptr;
0029 }
0030
0031 T& operator*() {
0032 BOOST_CONTRACT_DETAIL_DEBUG(ptr_);
0033 return *ptr_;
0034 }
0035
0036 T const& operator*() const {
0037 BOOST_CONTRACT_DETAIL_DEBUG(ptr_);
0038 return *ptr_;
0039 }
0040
0041 T* operator->() { return ptr_; }
0042 T const* operator->() const { return ptr_; }
0043
0044 BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(auto_ptr<T>, !!ptr_)
0045
0046 private:
0047 T* ptr_;
0048 };
0049
0050 } } }
0051
0052 #endif
0053