diff options
author | Lioncash <mathew1800@gmail.com> | 2020-08-07 13:55:50 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-08-07 14:09:57 +0200 |
commit | 8e86fa7e6033d7d65c781eb332d5d750f7ef4e26 (patch) | |
tree | 8c22b7d574b92de9077dc9c0e1d05fa2947b34b5 | |
parent | Merge pull request #4483 from lioncash/constexpr-hex (diff) | |
download | yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar.gz yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar.bz2 yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar.lz yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar.xz yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.tar.zst yuzu-8e86fa7e6033d7d65c781eb332d5d750f7ef4e26.zip |
-rw-r--r-- | src/common/concepts.h | 10 | ||||
-rw-r--r-- | src/core/hle/service/sm/sm.h | 2 | ||||
-rw-r--r-- | src/core/loader/loader.cpp | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/common/concepts.h b/src/common/concepts.h index db5fb373d..54252e778 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h @@ -23,10 +23,12 @@ concept IsSTLContainer = requires(T t) { t.size(); }; -// Check if type T is derived from T2 -template <typename T, typename T2> -concept IsBaseOf = requires { - std::is_base_of_v<T, T2>; +// TODO: Replace with std::derived_from when the <concepts> header +// is available on all supported platforms. +template <typename Derived, typename Base> +concept DerivedFrom = requires { + std::is_base_of_v<Base, Derived>; + std::is_convertible_v<const volatile Derived*, const volatile Base*>; }; } // namespace Common diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index b526a94fe..aabf166b7 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -57,7 +57,7 @@ public: ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name); ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name); - template <Common::IsBaseOf<Kernel::SessionRequestHandler> T> + template <Common::DerivedFrom<Kernel::SessionRequestHandler> T> std::shared_ptr<T> GetService(const std::string& service_name) const { auto service = registered_services.find(service_name); if (service == registered_services.end()) { diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index b8f8f1448..7c48e55e1 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -25,7 +25,7 @@ namespace Loader { namespace { -template <Common::IsBaseOf<AppLoader> T> +template <Common::DerivedFrom<AppLoader> T> std::optional<FileType> IdentifyFileLoader(FileSys::VirtualFile file) { const auto file_type = T::IdentifyType(file); if (file_type != FileType::Error) { |