Blender  V2.93
AutoPtrHelper.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include <memory>
25 
26 namespace Freestyle {
27 
28 template<typename T> class AutoPtr : public std::unique_ptr<T> {
29  public:
30  using std::unique_ptr<T>::unique_ptr;
31 
32  AutoPtr() : std::unique_ptr<T>()
33  {
34  }
35  AutoPtr(T *ptr) : std::unique_ptr<T>(ptr)
36  {
37  }
38 
39  /* Mimic behavior of legacy auto_ptr.
40  * Keep implementation as small as possible, hens delete assignment operator. */
41 
42  template<typename X> AutoPtr(AutoPtr<X> &other) : std::unique_ptr<T>(other.get())
43  {
44  other.release();
45  }
46 
47  using std::unique_ptr<T>::operator=;
48 
49  template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete;
50 };
51 
52 } /* namespace Freestyle */
AutoPtr(AutoPtr< X > &other)
Definition: AutoPtrHelper.h:42
AutoPtr & operator=(AutoPtr< X > &other)=delete
#define T
inherits from class Rep
Definition: AppCanvas.cpp:32
PointerRNA * ptr
Definition: wm_files.c:3157