SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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 <seqan3/std/concepts>
16#include <type_traits>
17
19
20namespace seqan3::detail
21{
23template <template <typename> typename rebind>
24struct simd_traits_has_rebind : std::true_type {};
25// NOTE: this definition should be used for seqan3::simd, but gcc has a bug that it will not fail silently if
26// simd_t is a pointer to a incomplete type. Furthermore the is_pointer_v should prevent those cases by checking the type
27// beforehand, but for some reasons the short-circuit semantic of `&&` does not work in this case and gcc still evaluates
28// the requires clause which in turn triggers the error.
29//
30// If this concept is used directly on incomplete types it will produces this compiler error:
31// error: invalid use of incomplete type ‘struct incomplete::template_type<int>’
32// requires std::same_as<decltype(a - b), simd_t>;
33template <typename simd_t>
34SEQAN3_CONCEPT simd_concept = requires (simd_t a, simd_t b)
35{
36 typename simd_traits<std::remove_reference_t<simd_t>>::scalar_type;
37 typename simd_traits<std::remove_reference_t<simd_t>>::mask_type;
38 typename simd_traits<std::remove_reference_t<simd_t>>::swizzle_type;
39 requires simd_traits_has_rebind<simd_traits<std::remove_reference_t<simd_t>>::template rebind>::value;
40
41 // require that static member variables are defined
42 requires std::integral<decltype(simd_traits<std::remove_reference_t<simd_t>>::length)>;
43 requires std::integral<decltype(simd_traits<std::remove_reference_t<simd_t>>::max_length)>;
44
45 // assume array access that returns a scalar_type type
46 SEQAN3_RETURN_TYPE_CONSTRAINT(a[0], std::convertible_to,
47 typename simd_traits<std::remove_reference_t<simd_t>>::scalar_type);
48
49 // require comparison operators
51 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
53 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
55 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
57 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
59 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
61 std::same_as, typename simd_traits<std::remove_reference_t<simd_t>>::mask_type);
62
63 // require arithmetic operators
72};
74
75} // namespace seqan3::detail
76
77namespace seqan3
78{
79
80inline namespace simd
81{
82
97template <typename simd_t>
98SEQAN3_CONCEPT simd_concept = !std::is_pointer_v<std::decay_t<simd_t>> && detail::simd_concept<simd_t>;
100
110template <typename t>
111SEQAN3_CONCEPT simd_index = simd::simd_concept<t> && requires ()
112{
113 requires std::integral<typename simd_traits<std::remove_reference_t<t>>::scalar_type>;
114};
116
117} // inline namespace simd
118
119} // namespace seqan3
The <concepts> header from C++20's standard library.
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57
Provides seqan3::simd::simd_traits.