diff options
author | crupest <crupest@outlook.com> | 2022-02-16 22:42:34 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-16 22:42:34 +0800 |
commit | f75ab0bd662c73d15057d746347d09bf94a992a6 (patch) | |
tree | 91efc33de481edf5304001d80b914b69cc0fb338 /include/cru/platform | |
parent | 2711b7032cafdc9bdbd6ae06db0325c91e6e7f63 (diff) | |
download | cru-f75ab0bd662c73d15057d746347d09bf94a992a6.tar.gz cru-f75ab0bd662c73d15057d746347d09bf94a992a6.tar.bz2 cru-f75ab0bd662c73d15057d746347d09bf94a992a6.zip |
...
Diffstat (limited to 'include/cru/platform')
-rw-r--r-- | include/cru/platform/Check.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/cru/platform/Check.h b/include/cru/platform/Check.h index 1750c7e8..8dc4faac 100644 --- a/include/cru/platform/Check.h +++ b/include/cru/platform/Check.h @@ -2,8 +2,8 @@ #include "Exception.h" #include "Resource.h" -#include "cru/common/String.h" #include "cru/common/Format.h" +#include "cru/common/String.h" #include <memory> #include <type_traits> @@ -12,7 +12,7 @@ namespace cru::platform { template <typename TTarget> TTarget* CheckPlatform(IPlatformResource* resource, const String& target_platform) { - Expects(resource); + if (resource == nullptr) return nullptr; const auto result = dynamic_cast<TTarget*>(resource); if (result == nullptr) { throw UnsupportPlatformException(Format( @@ -26,9 +26,9 @@ TTarget* CheckPlatform(IPlatformResource* resource, template <typename TTarget, typename TSource> std::shared_ptr<TTarget> CheckPlatform(const std::shared_ptr<TSource>& resource, const String& target_platform) { + if (resource == nullptr) return nullptr; static_assert(std::is_base_of_v<IPlatformResource, TSource>, "TSource must be a subclass of INativeResource."); - Expects(resource); const auto result = std::dynamic_pointer_cast<TTarget>(resource); if (result == nullptr) { throw UnsupportPlatformException(Format( |