# OpenShaderDesigner: Include/Utility/TemplateUtils.h Source File

Loading...
Searching...
No Matches
TemplateUtils.h
Go to the documentation of this file.
// =====================================================================================================================
// Copyright 2024 Medusa Slockbower
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =====================================================================================================================
#ifndef TEMPLATEUTILS_H
#define TEMPLATEUTILS_H
template<typename T, T V>
struct ConstantValue
{
using Type = T;
static constexpr Type Value = V;
constexpr operator Type() const noexcept { return Value; }
[[nodiscard]] constexpr Type operator()() const { return Value; }
};
template<bool V>
using BoolConstant = ConstantValue<bool, V>;
using TrueType = BoolConstant<true>;
using FalseType = BoolConstant<false>;
template<typename, typename>
inline static constexpr bool IsSame = false;
template<typename T>
inline static constexpr bool IsSame<T, T> = true;
template<typename...>
inline static constexpr bool IsUnique = TrueType{};
template<typename T, typename...Ts>
inline constexpr bool IsUnique<T, Ts...> = BoolConstant<(!IsSame<T, Ts> && ...) && IsUnique<Ts...>>{};
template<size_t I, typename T, typename...Ts>
struct GetPackElement
{
using Type = typename GetPackElement<I - 1, T, Ts...>::Type;
};
#endif //TEMPLATEUTILS_H
ConstantValue
Compile-time constant value.
Definition TemplateUtils.h:31
GetPackElement
Definition TemplateUtils.h:71