diff options
Diffstat (limited to 'src/common/concepts.h')
| -rw-r--r-- | src/common/concepts.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/common/concepts.h b/src/common/concepts.h index db5fb373d..5bef3ad67 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | namespace Common { | ||
| 8 | |||
| 9 | #include <type_traits> | 7 | #include <type_traits> |
| 10 | 8 | ||
| 9 | namespace Common { | ||
| 10 | |||
| 11 | // Check if type is like an STL container | 11 | // Check if type is like an STL container |
| 12 | template <typename T> | 12 | template <typename T> |
| 13 | concept IsSTLContainer = requires(T t) { | 13 | concept IsSTLContainer = requires(T t) { |
| @@ -23,10 +23,12 @@ concept IsSTLContainer = requires(T t) { | |||
| 23 | t.size(); | 23 | t.size(); |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | // Check if type T is derived from T2 | 26 | // TODO: Replace with std::derived_from when the <concepts> header |
| 27 | template <typename T, typename T2> | 27 | // is available on all supported platforms. |
| 28 | concept IsBaseOf = requires { | 28 | template <typename Derived, typename Base> |
| 29 | std::is_base_of_v<T, T2>; | 29 | concept DerivedFrom = requires { |
| 30 | std::is_base_of_v<Base, Derived>; | ||
| 31 | std::is_convertible_v<const volatile Derived*, const volatile Base*>; | ||
| 30 | }; | 32 | }; |
| 31 | 33 | ||
| 32 | } // namespace Common | 34 | } // namespace Common |