SeqAn3
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 
13 #pragma once
14 
15 #include <type_traits>
16 
18 #include <seqan3/std/concepts>
19 
20 namespace seqan3::detail
21 {
23 // NOTE: this definition should be used for seqan3::Simd, but gcc has a bug that it will not fail silently if
24 // simd_t is a pointer to a incomplete type. Furthermore the is_pointer_v should prevent those cases by checking the type
25 // beforehand, but for some reasons the short-circuit semantic of `&&` does not work in this case and gcc still evaluates
26 // the requires clause which in turn triggers the error.
27 //
28 // If this concept is used directly on incomplete types it will produces this compiler error:
29 // error: invalid use of incomplete type ‘struct incomplete::template_type<int>’
30 // requires std::Same<decltype(a - b), simd_t>;
31 template <typename simd_t>
32 SEQAN3_CONCEPT Simd = requires (simd_t a, simd_t b)
33 {
34  typename simd_traits<simd_t>::scalar_type;
35  typename simd_traits<simd_t>::mask_type;
36  typename simd_traits<simd_t>::swizzle_type;
37 
38  // require that static member variables are defined
41 
42  // assume array access that returns a scalar_type type
43  { a[0] } -> typename simd_traits<simd_t>::scalar_type;
44 
45  // require comparison operators
49  requires std::Same<decltype(a > b), typename simd_traits<simd_t>::mask_type>;
51  requires std::Same<decltype(a >= b), typename simd_traits<simd_t>::mask_type>;
52 
53  // require arithmetic operators
55  requires std::Same<decltype(a - b), simd_t>;
57  requires std::Same<decltype(a / b), simd_t>;
59  requires std::Same<decltype(a -= b), simd_t &>;
61  requires std::Same<decltype(a /= b), simd_t &>;
62 };
64 
65 } // namespace seqan3::detail
66 
67 namespace seqan3
68 {
69 
70 inline namespace simd
71 {
72 
86 template <typename simd_t>
88 SEQAN3_CONCEPT Simd = !std::is_pointer_v<std::decay_t<simd_t>> && detail::Simd<simd_t>;
90 
91 } // inline namespace simd
92 
93 } // namespace seqan3
Provides seqan3::simd::simd_traits.
The main SeqAn3 namespace.
The concept Integral is satisfied if and only if T is an integral type.
The Concepts library.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Definition: aligned_sequence_concept.hpp:35