SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
template_inspection.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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 ...> typename target_template,
59 typename ...source_arg_types>
61 requires requires ()
62 {
63 typename target_template<source_arg_types...>;
64 }
66struct transfer_template_args_onto<source_template<source_arg_types...>, target_template>
67{
69 using type = target_template<source_arg_types...>;
70};
71
76template <typename source_type, template <typename ...> typename target_template>
77using transfer_template_args_onto_t = typename transfer_template_args_onto<source_type, target_template>::type;
78
79// ----------------------------------------------------------------------------
80// transfer_template_vargs_onto
81// ----------------------------------------------------------------------------
82
84template <typename source_type, template <auto ...> typename target_template>
85struct transfer_template_vargs_onto
86{};
88
106template <template <auto ...> typename source_template,
107 template <auto ...> typename target_template,
108 auto ... source_varg_types>
110 requires requires ()
111 {
112 typename target_template<source_varg_types...>;
113 }
115struct transfer_template_vargs_onto<source_template<source_varg_types...>, target_template>
116{
118 using type = target_template<source_varg_types...>;
119};
120
125template <typename source_type, template <auto ...> typename target_template>
126using transfer_template_vargs_onto_t = typename transfer_template_vargs_onto<source_type, target_template>::type;
127
128// ----------------------------------------------------------------------------
129// is_type_specialisation_of_v
130// ----------------------------------------------------------------------------
131
144template <typename source_t, template <typename ...> typename target_template>
146{};
147
149template <typename source_t, template <typename ...> typename target_template>
151 requires (!std::same_as<transformation_trait_or_t<transfer_template_args_onto<source_t, target_template>, void>,
152 void>)
156{};
157
163template <typename source_t, template <typename ...> typename target_template>
164inline constexpr bool is_type_specialisation_of_v = is_type_specialisation_of<source_t, target_template>::value;
165
166// ----------------------------------------------------------------------------
167// is_value_specialisation_of_v
168// ----------------------------------------------------------------------------
169
171template <typename source_t, template <auto ...> typename target_template>
172struct is_value_specialisation_of : std::false_type
173{};
175
185template <typename source_t, template <auto ...> typename target_template>
187 requires (!std::same_as<transformation_trait_or_t<transfer_template_vargs_onto<source_t, target_template>, void>,
188 void>)
192{};
193
199template <typename source_t, template <auto ...> typename target_template>
200inline constexpr bool is_value_specialisation_of_v = is_value_specialisation_of<source_t, target_template>::value;
201
210template <typename fallback_t, template <typename ...> typename templ_t, typename ...spec_t>
212{
214 using type = fallback_t;
215};
216
218template <typename fallback_t, template <typename ...> typename templ_t, typename ...spec_t>
220 requires requires { typename templ_t<spec_t...>; }
222struct valid_template_spec_or<fallback_t, templ_t, spec_t...>
223{
225 using type = templ_t<spec_t...>;
226};
227
235template <typename fallback_t, template <typename ...> typename templ_t, typename ...spec_t>
236using valid_template_spec_or_t = typename valid_template_spec_or<fallback_t, templ_t, spec_t...>::type;
237
238// ----------------------------------------------------------------------------
239// template_specialisation_of
240// ----------------------------------------------------------------------------
241
257template <typename mytype, template <typename ...> typename type_template>
258concept template_specialisation_of = is_type_specialisation_of_v<mytype, type_template>;
259
261
262// ----------------------------------------------------------------------------
263// strip_type_identity
264// ----------------------------------------------------------------------------
265
270template <typename t>
273 t>;
274} // 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:77
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:236
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:126
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
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: template_inspection.hpp:156
Determines whether a source_type is a specialisation of another template.
Definition: template_inspection.hpp:146
Determines whether a source_type is a specialisation of another template.
Definition: template_inspection.hpp:192
target_template< source_arg_types... > type
The return type: the target type specialised by the unpacked types in the list.
Definition: template_inspection.hpp:69
target_template< source_varg_types... > type
The return type: the target type specialised by the unpacked types in the list.
Definition: template_inspection.hpp:118
templ_t< spec_t... > type
The resulting type.
Definition: template_inspection.hpp:225
Exposes templ_t<spec_t...> if that is valid, otherwise fallback_t.
Definition: template_inspection.hpp:212
fallback_t type
The resulting type.
Definition: template_inspection.hpp:214
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:200
Provides seqan3::detail::transformation_trait_or.