Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
drawing-item-ptr.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H
3#define INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H
4
5#include <memory>
6#include <type_traits>
7
8namespace Inkscape { class DrawingItem; }
9
14{
15 template <typename T>
16 void operator()(T *t)
17 {
18 static_assert(std::is_base_of_v<Inkscape::DrawingItem, T>);
19 t->unlink();
20 }
21};
22
29template <typename T>
30using DrawingItemPtr = std::unique_ptr<T, UnlinkDeleter>;
31
35template <typename T, typename... Args>
36auto make_drawingitem(Args&&... args)
37{
38 return DrawingItemPtr<T>(new T(std::forward<Args>(args)...));
39};
40
41#endif // INKSCAPE_DISPLAY_DRAWINGITEM_PTR_H
std::unique_ptr< T, UnlinkDeleter > DrawingItemPtr
Smart pointer used by the Object Tree to hold items in the Display Tree, like std::unique_ptr.
auto make_drawingitem(Args &&... args)
Convienence function to create a DrawingItemPtr, like std::make_unique.
Helper class to stream background task notifications as a series of messages.
Deleter object which calls the unlink() method of DrawingItem to schedule deferred destruction.
void operator()(T *t)