2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-02-09 22:23:21 +05:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Utility header for auto_ptr/unique_ptr selection
|
2015-02-09 22:23:21 +05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace Freestyle {
|
|
|
|
|
|
|
|
|
|
template<typename T> class AutoPtr : public std::unique_ptr<T> {
|
|
|
|
|
public:
|
2020-11-06 16:05:40 +01:00
|
|
|
using std::unique_ptr<T>::unique_ptr;
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
AutoPtr() : std::unique_ptr<T>() {}
|
|
|
|
|
AutoPtr(T *ptr) : std::unique_ptr<T>(ptr) {}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-25 23:13:02 +10:00
|
|
|
/* Mimic behavior of legacy auto_ptr.
|
|
|
|
|
* Keep implementation as small as possible, hens delete assignment operator. */
|
2020-06-18 15:18:26 +02:00
|
|
|
|
2015-02-09 22:23:21 +05:00
|
|
|
template<typename X> AutoPtr(AutoPtr<X> &other) : std::unique_ptr<T>(other.get())
|
|
|
|
|
{
|
|
|
|
|
other.release();
|
|
|
|
|
}
|
2020-06-18 15:18:26 +02:00
|
|
|
|
2020-11-06 16:05:40 +01:00
|
|
|
using std::unique_ptr<T>::operator=;
|
|
|
|
|
|
2020-06-25 23:13:02 +10:00
|
|
|
template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete;
|
2015-02-09 22:23:21 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} /* namespace Freestyle */
|