forked from ShuriZma/suyu
Merge pull request #4501 from lioncash/is_base_of
common/concepts: Rename IsBaseOf to DerivedFrom
This commit is contained in:
commit
53e94c7be8
|
@ -23,10 +23,12 @@ concept IsSTLContainer = requires(T t) {
|
||||||
t.size();
|
t.size();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if type T is derived from T2
|
// TODO: Replace with std::derived_from when the <concepts> header
|
||||||
template <typename T, typename T2>
|
// is available on all supported platforms.
|
||||||
concept IsBaseOf = requires {
|
template <typename Derived, typename Base>
|
||||||
std::is_base_of_v<T, T2>;
|
concept DerivedFrom = requires {
|
||||||
|
std::is_base_of_v<Base, Derived>;
|
||||||
|
std::is_convertible_v<const volatile Derived*, const volatile Base*>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
|
ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
|
||||||
ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(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 {
|
std::shared_ptr<T> GetService(const std::string& service_name) const {
|
||||||
auto service = registered_services.find(service_name);
|
auto service = registered_services.find(service_name);
|
||||||
if (service == registered_services.end()) {
|
if (service == registered_services.end()) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Loader {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <Common::IsBaseOf<AppLoader> T>
|
template <Common::DerivedFrom<AppLoader> T>
|
||||||
std::optional<FileType> IdentifyFileLoader(FileSys::VirtualFile file) {
|
std::optional<FileType> IdentifyFileLoader(FileSys::VirtualFile file) {
|
||||||
const auto file_type = T::IdentifyType(file);
|
const auto file_type = T::IdentifyType(file);
|
||||||
if (file_type != FileType::Error) {
|
if (file_type != FileType::Error) {
|
||||||
|
|
Loading…
Reference in New Issue