Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
traits.h
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4#include <utility>
5#include <cstddef>
6
7namespace ph
8{
9
10// TODO: variants that ignores return type
11
18template<typename A, typename B, typename C>
19concept CCanAdd = requires (A a, B b, C c)
20{
21 c = a + b;
22};
23
30template<typename A, typename B, typename C>
31concept CCanSubtract = requires (A a, B b, C c)
32{
33 c = a - b;
34};
35
42template<typename A, typename B, typename C>
43concept CCanMultiply = requires (A a, B b, C c)
44{
45 c = a * b;
46};
47
54template<typename A, typename B, typename C>
55concept CCanDivide = requires (A a, B b, C c)
56{
57 c = a / b;
58};
59
66
69template<typename Built, typename From, typename = void>
70struct IsBuildable : std::false_type {};
71
74template<typename Built, typename From>
76<
77 Built, From,
78 std::enable_if_t
79 <
80 std::is_convertible_v<From, Built> ||
81 std::is_constructible_v<Built, From>
82 >
83> : std::true_type {};
85
86template<typename ObjType>
87concept CSubscriptable = requires (ObjType obj, std::size_t index)
88{
89 obj[index];
90};
91
92template<CSubscriptable Ts>
93using TSubscriptedTypeOf = decltype(std::declval<Ts>()[0]);
94
97template<typename EnumType>
98concept CEnum = std::is_enum_v<EnumType>;
99
100template<typename EnumType>
102{
103 { EnumType::SIZE } -> std::convertible_to<EnumType>;
104};
105
109template<typename T>
110concept CNumber = std::is_arithmetic_v<T>;
111
112template<typename TypeA, typename TypeB>
113concept CSame = std::same_as<TypeA, TypeB>;
114
115template<typename TypeA, typename TypeB>
117
121template<typename DerivedType, typename BaseType>
122concept CDerived = std::derived_from<DerivedType, BaseType>;
123
127template<typename BaseType, typename DerivedType>
128concept CBase = std::derived_from<DerivedType, BaseType>;
129
130}// end namespace ph
Checks whether BaseType is a base of DerivedType. The result is also true if both types are the same;...
Definition traits.h:128
Check if instances of types can be added together.
Definition traits.h:19
Check if instances of types can be divided.
Definition traits.h:55
Check if instances of types can be multiplied together.
Definition traits.h:43
Check if instances of types can be subtracted.
Definition traits.h:31
Checks whether DerivedType is derived from BaseType. The result is also true if both types are the sa...
Definition traits.h:122
Whether the type is a scoped/unscoped enum.
Definition traits.h:98
Definition traits.h:101
Definition traits.h:116
Checks whether T supports arithmetic operations. Effectively checking std::is_arithmetic<>.
Definition traits.h:110
Definition traits.h:113
Definition traits.h:87
The root for all renderer implementations.
Definition EEngineProject.h:6
decltype(std::declval< Ts >()[0]) TSubscriptedTypeOf
Definition traits.h:93
Definition TAABB2D.h:96
Check if object conversion can be made.
Definition traits.h:70