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 
17 #include <seqan3/std/concepts>
18 
19 // ============================================================================
20 // complement()
21 // ============================================================================
22 
23 namespace seqan3::detail::adl_only
24 {
25 
27 template <typename ...args_t>
28 void complement(args_t ...) = delete;
29 
31 struct complement_fn
32 {
33 public:
34  SEQAN3_CPO_IMPL(2, seqan3::custom::alphabet<decltype(v)>::complement(v)) // explicit customisation
35  SEQAN3_CPO_IMPL(1, complement(v) ) // ADL
36  SEQAN3_CPO_IMPL(0, v.complement() ) // member
37 
38 public:
40  template <typename nucleotide_t>
42  requires requires (nucleotide_t const nucl)
43  {
44  { impl(priority_tag<2>{}, nucl) };
45  requires noexcept(impl(priority_tag<2>{}, nucl));
46  // requires std::common_with<decltype(impl(priority_tag<2>{}, nucl)), nucleotide_t>; // triggers an ICE
47  requires alphabet<decltype(impl(priority_tag<2>{}, nucl))>;
48  { impl(priority_tag<2>{}, impl(priority_tag<2>{}, nucl)) }; // you can take the complement again
49  }
51  constexpr auto operator()(nucleotide_t const nucl) const noexcept
52  {
53  return impl(priority_tag<2>{}, nucl);
54  }
55 };
56 
57 } // namespace seqan3::detail::adl_only
58 
59 namespace seqan3
60 {
61 
95 inline constexpr auto complement = detail::adl_only::complement_fn{};
97 
98 // ============================================================================
99 // nucleotide_alphabet concept
100 // ============================================================================
101 
127 template <typename t>
129 SEQAN3_CONCEPT nucleotide_alphabet = alphabet<t> && requires (t val)
130 {
131  { seqan3::complement(val) };
132 };
134 
135 } // namespace seqan3
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
concepts
The Concepts library.
nucleotide_alphabet
A concept that indicates whether an alphabet represents nucleotides.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
alphabet
The generic alphabet concept that covers most data types used in ranges.
seqan3::complement
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:95
concept.hpp
Core alphabet concept and free function/type trait wrappers.