nngn
Loading...
Searching...
No Matches
fundamental.h
Go to the documentation of this file.
1#ifndef NNGN_UTILS_CONCEPTS_FUNDAMENTAL_H
2#define NNGN_UTILS_CONCEPTS_FUNDAMENTAL_H
3
4#include <concepts>
5#include <cstddef>
6#include <type_traits>
7#include <version>
8
9namespace nngn {
10
11template<typename T>
12concept integral =
13#ifdef _LIBCPP_VERSION
14 std::is_integral_v<T>;
15#else
16 std::integral<T>;
17#endif
18
19template<typename T>
21#ifdef _LIBCPP_VERSION
22 std::is_integral_v<T> && !std::is_signed_v<T>;
23#else
24 std::unsigned_integral<T>;
25#endif
26
27template<typename T>
28concept arithmetic = std::is_arithmetic_v<T>;
29
30template<typename T>
31concept char_type =
33 && std::same_as<
34 signed char,
35 std::make_signed_t<std::remove_cv_t<T>>>;
36
37template<typename T>
38concept byte_type = std::is_same_v<std::byte, std::remove_cv_t<T>>;
39
40template<typename T>
41concept pointer = std::is_pointer_v<T>;
42
43template<typename T>
47);
48
49template<typename T>
50concept member_pointer = std::is_member_object_pointer_v<T>;
51
52template<typename T>
53concept function = std::is_function_v<T>;
54
55template<typename T>
57 std::is_pointer_v<T>
59
60template<typename T>
61concept member_function_pointer = std::is_member_function_pointer_v<T>;
62
63template<typename T>
65
66template<typename T>
67concept lvalue_ref = std::is_lvalue_reference_v<T>;
68
69template<typename T>
70concept rvalue_ref = std::is_rvalue_reference_v<T>;
71
72template<typename T>
73concept enum_ = std::is_enum_v<T>;
74
75template<typename T>
76concept c_enum = enum_<T> && std::convertible_to<T, int>;
77
78template<typename T>
79concept scoped_enum = enum_<T> && !std::convertible_to<T, int>;
80
81namespace detail {
82
83template<typename>
84inline constexpr bool is_stateless_lambda = false;
85
86template<typename R, typename T, typename ...Args>
87inline constexpr bool is_stateless_lambda<R(T::*)(Args...) const> =
88 std::convertible_to<T, R(*)(Args...)>;
89
90}
91
92template<typename T>
93concept stateless_lambda = requires {
94 { T{} };
95 { &T::operator() };
96 requires detail::is_stateless_lambda<decltype(&T::operator())>;
97};
98
99}
100
101#endif
local class const
Definition animation.lua:7
Definition fundamental.h:28
Definition fundamental.h:44
Definition fundamental.h:38
Definition fundamental.h:76
Definition fundamental.h:56
Definition fundamental.h:31
Definition fundamental.h:73
Definition fundamental.h:64
Definition fundamental.h:53
Definition fundamental.h:12
Definition fundamental.h:67
Definition fundamental.h:61
Definition fundamental.h:50
Definition fundamental.h:41
Definition fundamental.h:70
Definition fundamental.h:79
Definition fundamental.h:93
Definition fundamental.h:20
#define T(f0, f1, f2)
constexpr bool is_stateless_lambda
Definition fundamental.h:84
Definition audio.cpp:7
Definition debug.h:13