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