mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-26 02:14:22 +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
6190384fe1
commit
88bd3b0bbb
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