SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
17 #include <seqan3/std/concepts>
18 
19 // ============================================================================
20 // forwards
21 // ============================================================================
22 
24 namespace seqan3::custom
25 {
26 
27 void complement();
28 
29 } // namespace seqan3::custom
31 
32 // ============================================================================
33 // complement()
34 // ============================================================================
35 
37 {
38 
40 struct complement_fn
41 {
42 private:
43  SEQAN3_CPO_IMPL(2, complement(v) ) // ADL
44  SEQAN3_CPO_IMPL(1, seqan3::custom::complement(v) ) // customisation namespace
45  SEQAN3_CPO_IMPL(0, v.complement() ) // member
46 
47 public:
49  template <typename nucleotide_t>
51  requires requires (nucleotide_t const nucl) { { impl(priority_tag<2>{}, nucl) }; }
53  constexpr auto operator()(nucleotide_t const nucl) const noexcept
54  {
55  static_assert(noexcept(impl(priority_tag<2>{}, nucl)),
56  "Only overloads that are marked noexcept are picked up by seqan3::complement().");
57  static_assert(std::Same<nucleotide_t, decltype(impl(priority_tag<2>{}, nucl))>,
58  "The return type of your complement() implementation must be 'nucleotide_t'.");
59 
60  return impl(priority_tag<2>{}, nucl);
61  }
62 };
63 
64 } // namespace seqan3::detail::adl::only
65 
66 namespace seqan3
67 {
68 
104 inline constexpr auto complement = detail::adl::only::complement_fn{};
106 
107 // ============================================================================
108 // NucleotideAlphabet concept
109 // ============================================================================
110 
136 template <typename t>
138 SEQAN3_CONCEPT NucleotideAlphabet = Alphabet<t> && requires (t val)
139 {
140  { seqan3::complement(val) };
141 };
143 
144 } // namespace seqan3
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:104
#define SEQAN3_CPO_IMPL(PRIO, TERM)
A macro that helps defining the overload set of a customisation point.
Definition: customisation_point.hpp:45
Definition: concept.hpp:32
The main SeqAn3 namespace.
The Concepts library.
Core alphabet concept and free function/type trait wrappers.
A namespace for third party and standard library specialisations of SeqAn customisation points...
Definition: char.hpp:47
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.