sf: support service objects which must themselves be shared pointers
This commit is contained in:
@@ -50,11 +50,18 @@ namespace ams::sf {
|
||||
{ T::ShouldMitm(c) } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template<typename Interface, typename Impl, typename... Arguments> requires std::constructible_from<Impl, Arguments...>
|
||||
template<typename Interface, typename Impl, typename... Arguments>
|
||||
requires std::constructible_from<Impl, Arguments...>
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplHolder<Impl>> MakeShared(Arguments &&... args) {
|
||||
return std::make_shared<typename Interface::ImplHolder<Impl>>(std::forward<Arguments>(args)...);
|
||||
}
|
||||
|
||||
template<typename Interface, typename Impl, typename... Arguments>
|
||||
requires (std::constructible_from<Impl, Arguments...> && std::derived_from<Impl, std::enable_shared_from_this<Impl>>)
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplSharedPointer<Impl>> MakeShared(Arguments &&... args) {
|
||||
return std::make_shared<typename Interface::ImplSharedPointer<Impl>>(std::make_shared<Impl>(std::forward<Arguments>(args)...));
|
||||
}
|
||||
|
||||
template<typename Interface, typename Impl>
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl *impl) {
|
||||
return std::make_shared<typename Interface::ImplPointer<Impl>>(impl);
|
||||
|
||||
Reference in New Issue
Block a user