SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
alphabet/aminoacid/concept.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 <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>>,
67  std::remove_cvref_t<alphabet_type>,
68  std::type_identity<alphabet_type>>;
69 
73  template <typename alphabet_type = alphabet_t>
74  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)(
76  );
77 
87  template <typename alphabet_type = alphabet_t>
88  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)(
89  /*return*/ std::bool_constant<enable_aminoacid(alphabet_or_type_identity<alphabet_type>{})>::value == true /*;*/
90  );
91 
95  template <typename alphabet_type = alphabet_t>
96  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)(
97  /*return*/ std::is_base_of_v<seqan3::aminoacid_empty_base, alphabet_type> == true /*;*/
98  );
99 };
100 
101 } // namespace seqan3::detail::adl_only
102 
103 namespace seqan3
104 {
105 
151 template <typename t>
152 inline constexpr bool enable_aminoacid =
153  detail::adl_only::enable_aminoacid_cpo<std::remove_cvref_t<t>>::cpo_overload(detail::priority_tag<2>{});
154 
155 // ============================================================================
156 // concept
157 // ============================================================================
158 
175 template <typename type>
176 concept aminoacid_alphabet = alphabet<type> && enable_aminoacid<type>;
178 
179 } // 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:107
constexpr bool enable_aminoacid
A trait that indicates whether a type shall model seqan3::aminoacid_alphabet.
Definition: alphabet/aminoacid/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: alphabet/aminoacid/concept.hpp:35
Provides type traits for working with templates.