Blender  V3.3
AutoPtrHelper.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <memory>
11 
12 namespace Freestyle {
13 
14 template<typename T> class AutoPtr : public std::unique_ptr<T> {
15  public:
16  using std::unique_ptr<T>::unique_ptr;
17 
18  AutoPtr() : std::unique_ptr<T>()
19  {
20  }
21  AutoPtr(T *ptr) : std::unique_ptr<T>(ptr)
22  {
23  }
24 
25  /* Mimic behavior of legacy auto_ptr.
26  * Keep implementation as small as possible, hens delete assignment operator. */
27 
28  template<typename X> AutoPtr(AutoPtr<X> &other) : std::unique_ptr<T>(other.get())
29  {
30  other.release();
31  }
32 
33  using std::unique_ptr<T>::operator=;
34 
35  template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete;
36 };
37 
38 } /* namespace Freestyle */
AutoPtr(AutoPtr< X > &other)
Definition: AutoPtrHelper.h:28
AutoPtr & operator=(AutoPtr< X > &other)=delete
#define T
inherits from class Rep
Definition: AppCanvas.cpp:18
PointerRNA * ptr
Definition: wm_files.c:3480