FuncSketch
Loading...
Searching...
No Matches
acceptable_types.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <type_traits>
23
25
26namespace func_sketch::math {
27
32
33namespace details {
34
42template <typename ReceivedType, typename... AcceptableTypes>
44
53template <typename ReceivedType, typename FirstAcceptableType,
54 typename... RemainingAcceptableTypes>
55struct SelectTypeToUseImpl<ReceivedType, FirstAcceptableType,
56 RemainingAcceptableTypes...> {
58 using Type = std::conditional_t<
59 std::is_same_v<CommonType<ReceivedType, FirstAcceptableType>,
60 FirstAcceptableType>,
61 FirstAcceptableType,
62 typename SelectTypeToUseImpl<ReceivedType,
63 RemainingAcceptableTypes...>::Type>;
64};
65
72template <typename ReceivedType>
73struct SelectTypeToUseImpl<ReceivedType> {
76};
77
78} // namespace details
79
85template <typename... Types>
102 template <typename ReceivedType>
104 details::SelectTypeToUseImpl<ReceivedType, Types...>::Type;
105};
106
107namespace details {
108
114template <typename Type>
115struct IsAcceptableTypes : std::false_type {};
116
122template <typename... Types>
123struct IsAcceptableTypes<AcceptableTypes<Types...>> : std::true_type {};
124
125} // namespace details
126
133template <typename Type>
135
136} // namespace func_sketch::math
Definition of CommonType type.
Concept to check whether a type is func_sketch::math::AcceptableTypes.
Traits struct to handle acceptable number types.
details::SelectTypeToUseImpl< ReceivedType, Types... >::Type SelectTypeToUse
Select a type to use from the list of acceptable types.
Struct to indicate that there is no acceptable type.
Check whether a type is func_sketch::math::AcceptableTypes.
std::conditional_t< std::is_same_v< CommonType< ReceivedType, FirstAcceptableType >, FirstAcceptableType >, FirstAcceptableType, typename SelectTypeToUseImpl< ReceivedType, RemainingAcceptableTypes... >::Type > Type
Selected type. NoAcceptableType if there is no acceptable type.
NoAcceptableType Type
Selected type. NoAcceptableType if there is no acceptable type.
Internal implementation to select a type to use from a list of acceptable types.