mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 02:45:07 -04:00
sf: support service objects which must themselves be shared pointers
This commit is contained in:
parent
aa2d1e15ab
commit
2d9f5b6942
2 changed files with 42 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue