OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
TemplateUtils.h
Go to the documentation of this file.
1// =====================================================================================================================
2// Copyright 2024 Medusa Slockbower
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// =====================================================================================================================
15
16#ifndef TEMPLATEUTILS_H
17#define TEMPLATEUTILS_H
18
29template<typename T, T V>
31{
32 using Type = T;
33 static constexpr Type Value = V;
34
35 constexpr operator Type() const noexcept { return Value; }
36 [[nodiscard]] constexpr Type operator()() const { return Value; }
37};
38
43template<bool V>
45
48
52template<typename, typename>
53inline static constexpr bool IsSame = false;
54
55template<typename T>
56inline static constexpr bool IsSame<T, T> = true;
57
58template<typename...>
59inline static constexpr bool IsUnique = TrueType{};
60
66template<typename T, typename...Ts>
67inline constexpr bool IsUnique<T, Ts...> = BoolConstant<(!IsSame<T, Ts> && ...) && IsUnique<Ts...>>{};
68
69template<size_t I, typename T, typename...Ts>
71{
72 using Type = typename GetPackElement<I - 1, T, Ts...>::Type;
73};
74
75#endif //TEMPLATEUTILS_H
Compile-time constant value.
Definition TemplateUtils.h:31
Definition TemplateUtils.h:71