summaryrefslogtreecommitdiff
path: root/src/common/concepts.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/concepts.h')
-rw-r--r--src/common/concepts.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/common/concepts.h b/src/common/concepts.h
index a97555f6a..a9acff3e7 100644
--- a/src/common/concepts.h
+++ b/src/common/concepts.h
@@ -3,24 +3,14 @@
3 3
4#pragma once 4#pragma once
5 5
6#include <iterator>
6#include <type_traits> 7#include <type_traits>
7 8
8namespace Common { 9namespace Common {
9 10
10// Check if type is like an STL container 11// Check if type satisfies the ContiguousContainer named requirement.
11template <typename T> 12template <typename T>
12concept IsSTLContainer = requires(T t) { 13concept IsContiguousContainer = std::contiguous_iterator<typename T::iterator>;
13 typename T::value_type;
14 typename T::iterator;
15 typename T::const_iterator;
16 // TODO(ogniK): Replace below is std::same_as<void> when MSVC supports it.
17 t.begin();
18 t.end();
19 t.cbegin();
20 t.cend();
21 t.data();
22 t.size();
23};
24 14
25// TODO: Replace with std::derived_from when the <concepts> header 15// TODO: Replace with std::derived_from when the <concepts> header
26// is available on all supported platforms. 16// is available on all supported platforms.
@@ -34,4 +24,12 @@ concept DerivedFrom = requires {
34template <typename From, typename To> 24template <typename From, typename To>
35concept ConvertibleTo = std::is_convertible_v<From, To>; 25concept ConvertibleTo = std::is_convertible_v<From, To>;
36 26
27// No equivalents in the stdlib
28
29template <typename T>
30concept IsArithmetic = std::is_arithmetic_v<T>;
31
32template <typename T>
33concept IsIntegral = std::is_integral_v<T>;
34
37} // namespace Common 35} // namespace Common