BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
15#pragma once
16
17#include <concepts>
18
20
21// ============================================================================
22// complement()
23// ============================================================================
24
25namespace bio::alphabet
26{
27
68inline constexpr auto complement = []<typename alph_t>(alph_t const a)
69 requires(requires {
70 {
71 tag_invoke(custom::complement{}, a)
72 };
73 // NOTE we are using the trait here and not the concept, because the concept
74 // also checks explicit convertibility but we don't want to substitute into
75 // explicit constructors/conversion operators to prevent loops
76 requires std::is_convertible_v<alph_t, decltype(tag_invoke(custom::complement{}, a))>;
77 requires noexcept(tag_invoke(custom::complement{}, a));
78 })
79{
80 return tag_invoke(custom::complement{}, a);
81};
83
84// ============================================================================
85// nucleotide concept
86// ============================================================================
87
112template <typename t>
113concept nucleotide = alphabet<t> && requires(t val) {
114 {
116 };
117};
118
119} // namespace bio::alphabet
Core alphabet concept and free function/type trait wrappers.
The generic alphabet concept that covers most data types used in ranges.
Definition: concept.hpp:643
A concept that indicates whether an alphabet represents nucleotides.
Definition: concept.hpp:113
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:68
T is_convertible_v
The alphabet module's namespace.
Definition: aa10li.hpp:23
Customisation tag for bio::alphabet::complement.
Definition: tag.hpp:49