SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
33 {};
34 
35 } // namespace seqan3
36 
37 // ============================================================================
38 // enable_aminoacid
39 // ============================================================================
40 
41 namespace seqan3::detail::adl_only
42 {
43 
45 template <typename ...args_t>
46 void enable_aminoacid(args_t ...) = delete;
47 
49 struct enable_aminoacid_dispatcher
50 {
51 public:
52  // explicit customisation
54  // ADL
56  // default: derived from base class or not (valid for any type)
57  SEQAN3_CPO_IMPL(0, (std::is_base_of_v<seqan3::aminoacid_empty_base, strip_type_identity_t<t>>))
58 
59 
60  template <typename alph_t>
61  static constexpr bool dispatch() noexcept
62  {
63  if constexpr (std::is_nothrow_default_constructible_v<alph_t> &&
64  seqan3::is_constexpr_default_constructible_v<alph_t>)
65  {
66  return impl(priority_tag<2>{}, alph_t{});
67  }
68  else
69  {
70  return impl(priority_tag<2>{}, std::type_identity<alph_t>{});
71  }
72  }
73 };
74 
75 } // namespace seqan3::detail::adl_only
76 
77 namespace seqan3
78 {
79 
122 template <typename t>
123 inline constexpr bool enable_aminoacid = detail::adl_only::enable_aminoacid_dispatcher::dispatch<std::remove_cvref_t<t>>();
124 
125 // ============================================================================
126 // concept
127 // ============================================================================
128 
142 template <typename type>
144 SEQAN3_CONCEPT aminoacid_alphabet = alphabet<type> && enable_aminoacid<type>;
146 
147 } // namespace seqan3
std::bool_constant
seqan3::custom::alphabet
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: concept.hpp:48
SEQAN3_CPO_IMPL
#define SEQAN3_CPO_IMPL(PRIO, TERM)
A macro that helps defining the overload set of a customisation point.
Definition: customisation_point.hpp:45
template_inspection.hpp
Provides seqan3::type_list and auxiliary type traits.
seqan3::aminoacid_empty_base
This is an empty base class that can be inherited by types that shall model seqan3::aminoacid_alphabe...
Definition: concept.hpp:33
aminoacid_alphabet
A concept that indicates whether an alphabet represents amino acids.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
seqan3::enable_aminoacid
constexpr bool enable_aminoacid
A trait that indicates whether a type shall model seqan3::aminoacid_alphabet.
Definition: concept.hpp:123
std::type_identity
The identity transformation (a transformation_trait that returns the input).
alphabet
The generic alphabet concept that covers most data types used in ranges.
concept.hpp
Core alphabet concept and free function/type trait wrappers.
std::is_base_of_v
T is_base_of_v