HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
concepts.hpp
1// Copyright Take Vos 2020-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "type_traits.hpp"
8#include <type_traits>
9#include <string>
10#include <concepts>
11#include <limits>
12#include <coroutine>
13#include <chrono>
14
15namespace hi::inline v1 {
16
17template<typename T>
19
20template<typename T>
21concept numeric = is_numeric_v<T>;
22
23template<typename T>
24concept numeric_integral = is_numeric_integral_v<T>;
25
26template<typename T>
27concept numeric_signed_integral = is_numeric_signed_integral_v<T>;
28
29template<typename T>
30concept numeric_unsigned_integral = is_numeric_unsigned_integral_v<T>;
31
32template<typename T>
33concept arithmetic = std::is_arithmetic_v<T>;
34
35template<typename T>
36concept pointer = std::is_pointer_v<T>;
37
38template<typename T>
39concept reference = std::is_reference_v<T>;
40
41template<typename T>
42concept lvalue_reference = std::is_lvalue_reference_v<T>;
43
44template<typename T>
45concept rvalue_reference = std::is_rvalue_reference_v<T>;
46
47template<typename T>
48concept trivially_copyable = std::is_trivially_copyable_v<T>;
49
50template<typename Context, typename Expected>
51concept different_from = is_different_v<Context, Expected>;
52
53template<typename BaseType, typename DerivedType>
54concept base_of = std::is_base_of_v<BaseType, DerivedType>;
55
56template<typename BaseType, typename DerivedType>
57concept decayed_base_of = is_decayed_base_of_v<BaseType, DerivedType>;
58
59template<typename Context, typename Expected>
60concept derived_from = hi::is_derived_from_v<Context, Expected>;
61
62template<typename DerivedType, typename BaseType>
63concept decayed_derived_from = hi::is_decayed_derived_from_v<DerivedType, BaseType>;
64
65template<typename BaseType, typename DerivedType>
67std::same_as<BaseType, DerivedType>;
68
69template<typename BaseType, typename DerivedType>
71std::same_as<BaseType, DerivedType>;
72
73template<typename T>
74concept pre_incrementable = requires(T a) {
75 {
76 ++a
77 };
78 };
79
80template<typename T>
81concept pre_decrementable = requires(T a) {
82 {
83 --a
84 };
85 };
86
87template<typename T>
88concept to_stringable = requires(T v) {
89 {
90 to_string(v)
91 } -> std::convertible_to<std::string>;
92 };
93
94template<typename T>
95concept from_stringable = requires() {
96 {
97 from_string<T>(std::string_view{})
98 } -> std::convertible_to<T>;
99 };
100
101template<typename From, typename To>
102concept static_castableable = requires(From v) {
103 {
104 static_cast<To>(v)
105 } -> std::convertible_to<To>;
106 };
107
108template<typename T>
109concept sizeable = requires(T v) {
110 {
111 size(v)
112 } -> std::convertible_to<std::size_t>;
113 };
114
115template<typename T>
116concept scalar = std::is_scalar_v<T>;
117
122template<typename T>
123concept scoped_enum = std::is_enum_v<T>;
124
129template<typename Context, typename Expected, typename... OtherExpected>
130concept forward_of = is_forward_of_v<Context, Expected, OtherExpected...>;
131
136template<typename Context>
137concept byte_like = is_byte_like_v<Context>;
138
139} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:13
Definition concepts.hpp:18
Definition concepts.hpp:21
Definition concepts.hpp:24
Definition concepts.hpp:27
Definition concepts.hpp:30
Definition concepts.hpp:33
Definition concepts.hpp:36
Definition concepts.hpp:39
Definition concepts.hpp:42
Definition concepts.hpp:45
Definition concepts.hpp:48
Definition concepts.hpp:51
Definition concepts.hpp:54
Definition concepts.hpp:57
Definition concepts.hpp:60
Definition concepts.hpp:63
Definition concepts.hpp:66
Definition concepts.hpp:70
Definition concepts.hpp:74
Definition concepts.hpp:81
Definition concepts.hpp:88
Definition concepts.hpp:95
Definition concepts.hpp:102
Definition concepts.hpp:109
Definition concepts.hpp:116
Concept for std::is_scoped_enum_v<T>.
Definition concepts.hpp:123
True if T is a forwarded type of Forward.
Definition concepts.hpp:130
An array of this type will implicitly create objects within that array.
Definition concepts.hpp:137