SeqAn3
core_language.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
42 #include <type_traits>
43 
44 #include <range/v3/range_concepts.hpp>
45 #include <range/v3/utility/functional.hpp>
46 
47 #include <seqan3/core/platform.hpp>
48 #include <seqan3/std/concepts>
49 #include <seqan3/std/ranges>
50 
51 namespace seqan3::detail
52 {
53 
61 template <typename lhs_t, typename rhs_t>
63 concept weakly_equality_comparable_by_members_with_concept = requires (lhs_t const & lhs, rhs_t const & rhs)
64 {
65  lhs.operator==(rhs); std::Boolean<decltype(lhs.operator==(rhs))>;
66  lhs.operator!=(rhs); std::Boolean<decltype(lhs.operator!=(rhs))>;
67 };
69 
72 template <typename lhs_t, typename rhs_t>
74 concept weakly_ordered_by_members_with_concept = requires (lhs_t const & lhs, rhs_t const & rhs)
75 {
76  lhs.operator< (rhs); std::Boolean<decltype(lhs.operator< (rhs))>;
77  lhs.operator> (rhs); std::Boolean<decltype(lhs.operator> (rhs))>;
78  lhs.operator<=(rhs); std::Boolean<decltype(lhs.operator<=(rhs))>;
79  lhs.operator>=(rhs); std::Boolean<decltype(lhs.operator>=(rhs))>;
80 };
82 
86 template <typename source_t, typename target_t>
88 concept convertible_to_by_member_concept = requires (source_t s)
89 {
90  { s.operator target_t() } -> target_t;
91 };
94 
95 } // seqan3::detail
96 
97 namespace seqan3
98 {
99 
110 template <typename t1, typename t2>
112 concept weakly_ordered_with_concept = requires (std::remove_reference_t<t1> const & v1,
113  std::remove_reference_t<t2> const & v2)
114 {
115  { v1 < v2 } -> bool &&;
116  { v1 <= v2 } -> bool &&;
117  { v2 > v1 } -> bool &&;
118  { v2 >= v1 } -> bool &&;
119 };
121 
125 template <typename t, typename u>
127 concept implicitly_convertible_to_concept = std::is_convertible_v<t, u>;
129 
133 template <typename t, typename u>
135 concept explicitly_convertible_to_concept = requires (t vt) { { static_cast<u>(vt)}; };
137 
142 template <typename t>
144 concept arithmetic_concept = std::is_arithmetic_v<t>;
146 
152 template <typename t>
154 concept floating_point_concept = arithmetic_concept<t> && std::is_floating_point_v<t>;
156 
162 
164 template <typename t>
165 concept char_concept = std::Integral<t> &&
167 #ifdef __cpp_char8_t
169 #endif
172 
178 template <typename t>
180 concept trivially_destructible_concept = std::Destructible<t> && std::is_trivially_destructible_v<t>;
182 
188 template <typename t>
190 concept trivially_copyable_concept = std::Copyable<t> && std::is_trivially_copyable_v<t>;
192 
199 template <typename t>
201 concept trivial_concept = trivially_copyable_concept<t> && trivially_destructible_concept<t> && std::is_trivial_v<t>;
203 
208 template <typename t>
210 concept standard_layout_concept = std::is_standard_layout_v<t>;
212 
222 template <typename t, typename u>
224 concept weakly_assignable_concept = std::is_assignable_v<t, u>;
226 
227 } // namespace seqan3
Contains platform and dependency checks.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
The concept Integral is satisfied if and only if T is an integral type.
The Concepts library.
Adaptations of concepts from the Ranges TS.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Definition: aligned_sequence_concept.hpp:288
Provides C++20 additions to the type_traits header.
Specifies that a type can be used in Boolean contexts.
The concept std::Destructible specifies the concept of all types whose instances can safely be destro...
Subsumes std::Movable, std::CopyConstructible, and requires that the type be std::Assignable bool fro...