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 "../macros.hpp"
9#include <type_traits>
10#include <string>
11#include <concepts>
12#include <limits>
13#include <coroutine>
14#include <chrono>
15
16hi_export_module(hikogui.utility.concepts);
17
18hi_export namespace hi { inline namespace v1 {
19
20template<typename T>
22
23template<typename T>
25
26template<typename T>
28
29template<typename T>
31
32template<typename T>
34
35template<typename T>
36concept arithmetic = std::is_arithmetic_v<T>;
37
38template<typename T>
39concept pointer = std::is_pointer_v<T>;
40
41template<typename T>
42concept reference = std::is_reference_v<T>;
43
44template<typename T>
45concept lvalue_reference = std::is_lvalue_reference_v<T>;
46
47template<typename T>
48concept rvalue_reference = std::is_rvalue_reference_v<T>;
49
50template<typename T>
51concept trivially_copyable = std::is_trivially_copyable_v<T>;
52
53template<typename Context, typename Expected>
55
56template<typename BaseType, typename DerivedType>
57concept base_of = std::is_base_of_v<BaseType, DerivedType>;
58
59template<typename BaseType, typename DerivedType>
61
62template<typename Context, typename Expected>
64
65template<typename DerivedType, typename BaseType>
67
68template<typename BaseType, typename DerivedType>
69concept strict_base_of = base_of<BaseType, DerivedType> && !std::same_as<BaseType, DerivedType>;
70
71template<typename BaseType, typename DerivedType>
72concept strict_derived_from = derived_from<BaseType, DerivedType> && !std::same_as<BaseType, DerivedType>;
73
74template<typename T>
75concept pre_incrementable = requires(T a) {
76 {
77 ++a
78 };
79};
80
81template<typename T>
82concept pre_decrementable = requires(T a) {
83 {
84 --a
85 };
86};
87
88template<typename T>
89concept to_stringable = requires(T v) {
90 {
91 to_string(v)
92 } -> std::convertible_to<std::string>;
93};
94
95template<typename T>
96concept from_stringable = requires() {
97 {
98 from_string<T>(std::string_view{})
99 } -> std::convertible_to<T>;
100};
101
102template<typename From, typename To>
103concept static_castableable = requires(From v) {
104 {
105 static_cast<To>(v)
106 } -> std::convertible_to<To>;
107};
108
109template<typename T>
110concept sizeable = requires(T v) {
111 {
112 size(v)
113 } -> std::convertible_to<std::size_t>;
114};
115
116template<typename T>
117concept scalar = std::is_scalar_v<T>;
118
123template<typename T>
124concept scoped_enum = std::is_enum_v<T>;
125
130template<typename Context, typename Expected, typename... OtherExpected>
131concept forward_of = is_forward_of_v<Context, Expected, OtherExpected...>;
132
137template<typename Context>
139
140}} // namespace hi::v1
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
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:75
Definition concepts.hpp:82
Definition concepts.hpp:89
Definition concepts.hpp:96
Definition concepts.hpp:103
Definition concepts.hpp:110
Definition concepts.hpp:117
Concept for std::is_scoped_enum_v<T>.
Definition concepts.hpp:124
True if T is a forwarded type of Forward.
Definition concepts.hpp:131
An array of this type will implicitly create objects within that array.
Definition concepts.hpp:138