SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
template_inspection.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
11#pragma once
12
13#include <concepts>
14
16
17namespace seqan3::detail
18{
19
20// ----------------------------------------------------------------------------
21// transfer_template_args_onto
22// ----------------------------------------------------------------------------
23
25template <typename source_type, template <typename...> typename target_template>
26struct transfer_template_args_onto
27{};
29
54template <template <typename...> typename source_template,
55 template <typename...>
56 typename target_template,
57 typename... source_arg_types>
58 requires requires () { typename target_template<source_arg_types...>; }
59struct transfer_template_args_onto<source_template<source_arg_types...>, target_template>
60{
62 using type = target_template<source_arg_types...>;
63};
64
69template <typename source_type, template <typename...> typename target_template>
70using transfer_template_args_onto_t = typename transfer_template_args_onto<source_type, target_template>::type;
71
72// ----------------------------------------------------------------------------
73// transfer_template_vargs_onto
74// ----------------------------------------------------------------------------
75
77template <typename source_type, template <auto...> typename target_template>
78struct transfer_template_vargs_onto
79{};
81
99template <template <auto...> typename source_template,
100 template <auto...>
101 typename target_template,
102 auto... source_varg_types>
103 requires requires () { typename target_template<source_varg_types...>; }
104struct transfer_template_vargs_onto<source_template<source_varg_types...>, target_template>
105{
107 using type = target_template<source_varg_types...>;
108};
109
114template <typename source_type, template <auto...> typename target_template>
115using transfer_template_vargs_onto_t = typename transfer_template_vargs_onto<source_type, target_template>::type;
116
117// ----------------------------------------------------------------------------
118// is_type_specialisation_of_v
119// ----------------------------------------------------------------------------
120
133template <typename source_t, template <typename...> typename target_template>
134struct is_type_specialisation_of : public std::false_type
135{};
136
138template <template <typename...> typename source_t, typename... source_args>
139struct is_type_specialisation_of<source_t<source_args...>, source_t> : public std::true_type
140{};
141
147template <typename source_t, template <typename...> typename target_template>
148inline constexpr bool is_type_specialisation_of_v = is_type_specialisation_of<source_t, target_template>::value;
149
150// ----------------------------------------------------------------------------
151// is_value_specialisation_of_v
152// ----------------------------------------------------------------------------
153
155template <typename source_t, template <auto...> typename target_template>
156struct is_value_specialisation_of : std::false_type
157{};
159
169template <template <auto...> typename source_t, auto... source_args>
170struct is_value_specialisation_of<source_t<source_args...>, source_t> : public std::true_type
171{};
172
178template <typename source_t, template <auto...> typename target_template>
179inline constexpr bool is_value_specialisation_of_v = is_value_specialisation_of<source_t, target_template>::value;
180
189template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
190struct valid_template_spec_or
191{
193 using type = fallback_t;
194};
195
197template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
198 requires requires { typename templ_t<spec_t...>; }
199struct valid_template_spec_or<fallback_t, templ_t, spec_t...>
200{
202 using type = templ_t<spec_t...>;
203};
204
212template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
213using valid_template_spec_or_t = typename valid_template_spec_or<fallback_t, templ_t, spec_t...>::type;
214
215// ----------------------------------------------------------------------------
216// template_specialisation_of
217// ----------------------------------------------------------------------------
218
234template <typename mytype, template <typename...> typename type_template>
235concept template_specialisation_of = is_type_specialisation_of_v<mytype, type_template>;
236
238
239// ----------------------------------------------------------------------------
240// strip_type_identity
241// ----------------------------------------------------------------------------
242
247template <typename t>
248using strip_type_identity_t =
249 std::conditional_t<is_type_specialisation_of_v<t, std::type_identity>, transformation_trait_or_t<t, void>, t>;
250} // namespace seqan3::detail
constexpr bool is_value_specialisation_of_v
Helper variable template for seqan3::detail::is_value_specialisation_of (unary_type_trait shortcut).
Definition template_inspection.hpp:179
Provides seqan3::detail::transformation_trait_or.
Hide me