mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
ObjCClass: Remove virtual destructor and add move operations
ObjCClass doesn't have other virtual methods; it is not intended to be used as an interface or dynamic type. Removing the virtual destructor is intended to promote composition over inheritance when using this type.
This commit is contained in:
parent
8799a73d6a
commit
1f4cc7bbb1
1 changed files with 11 additions and 1 deletions
|
|
@ -317,7 +317,7 @@ struct ObjCClass
|
|||
jassert (cls != nil);
|
||||
}
|
||||
|
||||
virtual ~ObjCClass()
|
||||
~ObjCClass()
|
||||
{
|
||||
auto kvoSubclassName = String ("NSKVONotifying_") + class_getName (cls);
|
||||
|
||||
|
|
@ -325,6 +325,16 @@ struct ObjCClass
|
|||
objc_disposeClassPair (cls);
|
||||
}
|
||||
|
||||
ObjCClass (ObjCClass&& other) noexcept
|
||||
: cls (std::exchange (other.cls, {})) {}
|
||||
|
||||
ObjCClass& operator= (ObjCClass&& other) noexcept
|
||||
{
|
||||
auto tmp = std::move (other);
|
||||
std::swap (tmp.cls, cls);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void registerClass()
|
||||
{
|
||||
if (cls != nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue