1
0
Fork 0
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:
Anthony Nicholls 2023-12-01 20:52:48 +00:00
parent 2cc41fff40
commit 2685604eb3
2 changed files with 13 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;
}
}
};