SeqAn3  3.0.1
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::same_as<nucleotide_t, decltype(impl(priority_tag<2>{}, nucl))>;
47  }
49  constexpr nucleotide_t operator()(nucleotide_t const nucl) const noexcept
50  {
51  return impl(priority_tag<2>{}, nucl);
52  }
53 };
54 
55 } // namespace seqan3::detail::adl_only
56 
57 namespace seqan3
58 {
59 
93 inline constexpr auto complement = detail::adl_only::complement_fn{};
95 
96 // ============================================================================
97 // nucleotide_alphabet concept
98 // ============================================================================
99 
125 template <typename t>
127 SEQAN3_CONCEPT nucleotide_alphabet = alphabet<t> && requires (t val)
128 {
129  { seqan3::complement(val) };
130 };
132 
133 } // namespace seqan3
seqan3::custom::alphabet
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: concept.hpp:46
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.
same_as
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type.
nucleotide_alphabet
A concept that indicates whether an alphabet represents nucleotides.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
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:93
concept.hpp
Core alphabet concept and free function/type trait wrappers.