open-cpp-utils 0.0.1
Loading...
Searching...
No Matches
template_utils.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
19namespace open_cpp_utils
20{
21
32template<typename T, T V>
34{
35 using type = T;
36 static constexpr type value = V;
37
38 constexpr operator type() const noexcept { return value; }
39 [[nodiscard]] constexpr type operator()() const { return value; }
40};
41
46template<bool V>
48
51
55template<typename, typename>
56inline static constexpr bool is_same = false_type{};
57
61template<typename T>
62inline static constexpr bool is_same<T, T> = true_type{};
63
68template<typename...Ts>
69inline static constexpr bool is_unique = true_type{};
70
71template<typename T, typename...Ts>
72inline constexpr bool is_unique<T, Ts...> = bool_constant<(!is_same<T, Ts> && ...) && is_unique<Ts...>>{};
73
74}
75
76#endif //TEMPLATEUTILS_H
Compile-time constant value.
Definition template_utils.h:34
constant_value< bool, V > bool_constant
Compile-time constant boolean value.
Definition template_utils.h:47
bool_constant< true > true_type
Constant True value.
Definition template_utils.h:49