mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
SharedResourcePointer: Allow objects with private constructors
This commit is contained in:
parent
2cc41fff40
commit
2685604eb3
2 changed files with 13 additions and 1 deletions
|
|
@ -153,7 +153,7 @@ private:
|
|||
if (auto locked = ptr.lock())
|
||||
return locked;
|
||||
|
||||
auto shared = std::make_shared<SharedObjectType>();
|
||||
const std::shared_ptr<SharedObjectType> shared (new SharedObjectType());
|
||||
ptr = shared;
|
||||
return shared;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,18 @@ public:
|
|||
|
||||
expect (SharedResourcePointer<Object>::getSharedObjectWithoutCreating() == std::nullopt);
|
||||
}
|
||||
|
||||
beginTest ("Create objects with private constructors");
|
||||
{
|
||||
class ObjectWithPrivateConstructor
|
||||
{
|
||||
private:
|
||||
ObjectWithPrivateConstructor() = default;
|
||||
friend SharedResourcePointer<ObjectWithPrivateConstructor>;
|
||||
};
|
||||
|
||||
SharedResourcePointer<ObjectWithPrivateConstructor> instance;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue