2 * qpsnr (C) 2010 E. Oriani, ema <AT> fastwebnet <DOT> it
4 * This file is part of qpsnr.
6 * qpsnr is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * qpsnr is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with qpsnr. If not, see <http://www.gnu.org/licenses/>.
21 * myNZB (C) 2009 E. Oriani, ema <AT> fastwebnet <DOT> it
23 * This file is part of myNZB.
25 * myNZB is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
30 * myNZB is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with myNZB. If not, see <http://www.gnu.org/licenses/>.
39 #ifndef _SHARED_PTR_H_
40 #define _SHARED_PTR_H_
48 typedef unsigned int count_type;
56 shared_ptr(const ptr_type& in) :
59 _count = new (std::nothrow) count_type;
63 throw std::bad_alloc();
68 shared_ptr(const shared_ptr& in)
72 if (_count) *_count += 1;
75 shared_ptr& operator=(const shared_ptr& in)
89 if (_count) *_count += 1;
106 ptr_type get(void) const
111 count_type get_count(void) const
113 if (_count) return *_count;
117 ptr_type operator->() const
122 type& operator*() const
128 bool operator==(shared_ptr<U>& in)
130 return _ptr == in._ptr;
134 bool operator!=(shared_ptr<U>& in)
136 return _ptr != in._ptr;
140 bool operator<(shared_ptr<U>& in)
142 return _ptr < in._ptr;
149 #endif //_SHARED_PTR_H_