SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
concept.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 <type_traits>
17 
20 
21 // ============================================================================
22 // aminoacid_empty_base
23 // ============================================================================
24 
25 namespace seqan3
26 {
27 
35 {};
36 
37 } // namespace seqan3
38 
39 // ============================================================================
40 // enable_aminoacid
41 // ============================================================================
42 
43 namespace seqan3::detail::adl_only
44 {
45 
47 template <typename ...args_t>
48 void enable_aminoacid(args_t ...) = delete;
49 
52 template <typename alphabet_t>
53 struct enable_aminoacid_cpo : public detail::customisation_point_object<enable_aminoacid_cpo<alphabet_t>, 2>
54 {
56  using base_t = detail::customisation_point_object<enable_aminoacid_cpo<alphabet_t>, 2>;
58  using base_t::base_t;
59 
63  template <typename alphabet_type>
64  using alphabet_or_type_identity
66  seqan3::is_constexpr_default_constructible_v<std::remove_cvref_t<alphabet_type>>,
69 
73  template <typename alphabet_type = alphabet_t>
74  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)
75  (
77  );
78 
88  template <typename alphabet_type = alphabet_t>
89  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)
90  (
91  /*return*/ std::bool_constant<enable_aminoacid(alphabet_or_type_identity<alphabet_type>{})>::value == true /*;*/
92  );
93 
97  template <typename alphabet_type = alphabet_t>
98  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)
99  (
100  /*return*/ std::is_base_of_v<seqan3::aminoacid_empty_base, alphabet_type> == true /*;*/
101  );
102 };
103 
104 } // namespace seqan3::detail::adl_only
105 
106 namespace seqan3
107 {
108 
154 template <typename t>
155 inline constexpr bool enable_aminoacid =
156  detail::adl_only::enable_aminoacid_cpo<std::remove_cvref_t<t>>::cpo_overload(detail::priority_tag<2>{});
157 
158 // ============================================================================
159 // concept
160 // ============================================================================
161 
178 template <typename type>
179 SEQAN3_CONCEPT aminoacid_alphabet = alphabet<type> && enable_aminoacid<type>;
181 
182 } // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition: customisation_point.hpp:113
Provides type traits for working with templates.
constexpr bool enable_aminoacid
A trait that indicates whether a type shall model seqan3::aminoacid_alphabet.
Definition: concept.hpp:146
The generic alphabet concept that covers most data types used in ranges.
A concept that indicates whether an alphabet represents amino acids.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
This is an empty base class that can be inherited by types that shall model seqan3::aminoacid_alphabe...
Definition: concept.hpp:35