SeqAn3 3.3.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// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
14#pragma once
15
16#include <concepts>
17
19
20namespace seqan3::detail
21{
22
23// ----------------------------------------------------------------------------
24// transfer_template_args_onto
25// ----------------------------------------------------------------------------
26
28template <typename source_type, template <typename...> typename target_template>
29struct transfer_template_args_onto
30{};
32
57template <template <typename...> typename source_template,
58 template <typename...>
59 typename target_template,
60 typename... source_arg_types>
61 requires requires () { typename target_template<source_arg_types...>; }
62struct transfer_template_args_onto<source_template<source_arg_types...>, target_template>
63{
65 using type = target_template<source_arg_types...>;
66};
67
72template <typename source_type, template <typename...> typename target_template>
73using transfer_template_args_onto_t = typename transfer_template_args_onto<source_type, target_template>::type;
74
75// ----------------------------------------------------------------------------
76// transfer_template_vargs_onto
77// ----------------------------------------------------------------------------
78
80template <typename source_type, template <auto...> typename target_template>
81struct transfer_template_vargs_onto
82{};
84
102template <template <auto...> typename source_template,
103 template <auto...>
104 typename target_template,
105 auto... source_varg_types>
106 requires requires () { typename target_template<source_varg_types...>; }
107struct transfer_template_vargs_onto<source_template<source_varg_types...>, target_template>
108{
110 using type = target_template<source_varg_types...>;
111};
112
117template <typename source_type, template <auto...> typename target_template>
118using transfer_template_vargs_onto_t = typename transfer_template_vargs_onto<source_type, target_template>::type;
119
120// ----------------------------------------------------------------------------
121// is_type_specialisation_of_v
122// ----------------------------------------------------------------------------
123
136template <typename source_t, template <typename...> typename target_template>
138{};
139
141template <typename source_t, template <typename...> typename target_template>
142 requires (
143 !std::same_as<transformation_trait_or_t<transfer_template_args_onto<source_t, target_template>, void>, void>)
146{};
147
153template <typename source_t, template <typename...> typename target_template>
154inline constexpr bool is_type_specialisation_of_v = is_type_specialisation_of<source_t, target_template>::value;
155
156// ----------------------------------------------------------------------------
157// is_value_specialisation_of_v
158// ----------------------------------------------------------------------------
159
161template <typename source_t, template <auto...> typename target_template>
162struct is_value_specialisation_of : std::false_type
163{};
165
175template <typename source_t, template <auto...> typename target_template>
176 requires (
177 !std::same_as<transformation_trait_or_t<transfer_template_vargs_onto<source_t, target_template>, void>, void>)
178struct is_value_specialisation_of<source_t, target_template> :
180{};
181
187template <typename source_t, template <auto...> typename target_template>
188inline constexpr bool is_value_specialisation_of_v = is_value_specialisation_of<source_t, target_template>::value;
189
198template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
200{
202 using type = fallback_t;
203};
204
206template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
207 requires requires { typename templ_t<spec_t...>; }
208struct valid_template_spec_or<fallback_t, templ_t, spec_t...>
209{
211 using type = templ_t<spec_t...>;
212};
213
221template <typename fallback_t, template <typename...> typename templ_t, typename... spec_t>
222using valid_template_spec_or_t = typename valid_template_spec_or<fallback_t, templ_t, spec_t...>::type;
223
224// ----------------------------------------------------------------------------
225// template_specialisation_of
226// ----------------------------------------------------------------------------
227
243template <typename mytype, template <typename...> typename type_template>
244concept template_specialisation_of = is_type_specialisation_of_v<mytype, type_template>;
245
247
248// ----------------------------------------------------------------------------
249// strip_type_identity
250// ----------------------------------------------------------------------------
251
256template <typename t>
259} // namespace seqan3::detail
typename transfer_template_args_onto< source_type, target_template >::type transfer_template_args_onto_t
Shortcut for seqan3::detail::transfer_template_args_onto (transformation_trait shortcut).
Definition: template_inspection.hpp:73
typename valid_template_spec_or< fallback_t, templ_t, spec_t... >::type valid_template_spec_or_t
Helper for seqan3::detail::valid_template_spec_or (transformation_trait shortcut).
Definition: template_inspection.hpp:222
typename transfer_template_vargs_onto< source_type, target_template >::type transfer_template_vargs_onto_t
Shortcut for seqan3::detail::transfer_template_vargs_onto (transformation_trait shortcut).
Definition: template_inspection.hpp:118
typename transformation_trait_or< type_t, default_t >::type transformation_trait_or_t
Helper type of seqan3::detail::transformation_trait_or (transformation_trait shortcut).
Definition: transformation_trait_or.hpp:51
Provides concept seqan3::template_specialisation_of<mytype, [...]> for checking the type specialisati...
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Determines whether a source_type is a specialisation of another template.
Definition: template_inspection.hpp:138
target_template< source_arg_types... > type
The return type: the target type specialised by the unpacked types in the list.
Definition: template_inspection.hpp:65
target_template< source_varg_types... > type
The return type: the target type specialised by the unpacked types in the list.
Definition: template_inspection.hpp:110
templ_t< spec_t... > type
The resulting type.
Definition: template_inspection.hpp:211
Exposes templ_t<spec_t...> if that is valid, otherwise fallback_t.
Definition: template_inspection.hpp:200
fallback_t type
The resulting type.
Definition: template_inspection.hpp:202
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:188
Provides seqan3::detail::transformation_trait_or.