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>
66concept strict_base_of = base_of<BaseType, DerivedType> && !std::same_as<BaseType, DerivedType>;
67
68template<typename BaseType, typename DerivedType>
69concept strict_derived_from = derived_from<BaseType, DerivedType> && !std::same_as<BaseType, DerivedType>;
70
71template<typename T>
72concept pre_incrementable = requires(T a)
73{
74 {++a};
75};
76
77template<typename T>
78concept pre_decrementable = requires(T a)
79{
80 {--a};
81};
82
83template<typename T>
84concept to_stringable = requires(T v)
85{
86 {
87 to_string(v)
88 } -> std::convertible_to<std::string>;
89};
90
91template<typename T>
92concept from_stringable = requires()
93{
94 {
95 from_string<T>(std::string_view{})
96 } -> std::convertible_to<T>;
97};
98
99template<typename From, typename To>
100concept static_castableable = requires(From v)
101{
102 {
103 static_cast<To>(v)
104 } -> std::convertible_to<To>;
105};
106
107template<typename T>
108concept sizeable = requires(T v)
109{
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
132} // namespace hi::inline v1
constexpr std::string to_string(std::u32string_view rhs) noexcept
Conversion from UTF-32 to UTF-8.
Definition to_string.hpp:215
DOXYGEN BUG.
Definition algorithm.hpp:15
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:69
Definition concepts.hpp:72
Definition concepts.hpp:78
Definition concepts.hpp:84
Definition concepts.hpp:92
Definition concepts.hpp:100
Definition concepts.hpp:108
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