SeqAn3
iterator.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 <iterator>
43 #include <type_traits>
44 
45 #include <range/v3/utility/iterator_traits.hpp>
46 
47 #include <seqan3/core/platform.hpp>
49 #include <seqan3/std/iterator>
50 #include <seqan3/std/ranges>
51 
52 namespace seqan3
53 {
54 
59 // ----------------------------------------------------------------------------
60 // value_type
61 // ----------------------------------------------------------------------------
62 
66 template <std::InputIterator it_t>
67 struct value_type<it_t>
68 {
70  using type = typename std::iterator_traits<std::remove_reference_t<it_t>>::value_type;
71 };
72 
73 // see specialisation for ranges in core/metafunction/range.hpp
74 
75 // ----------------------------------------------------------------------------
76 // reference
77 // ----------------------------------------------------------------------------
78 
82 template <std::InputIterator it_t>
83 struct reference<it_t>
84 {
86  using type = typename std::iterator_traits<std::remove_reference_t<it_t>>::reference;
87 };
88 
89 // see specialisation for ranges in core/metafunction/range.hpp
90 
91 // ----------------------------------------------------------------------------
92 // rvalue_reference
93 // ----------------------------------------------------------------------------
94 
98 template <std::InputIterator it_t>
99 struct rvalue_reference<it_t>
100 {
102  using type = decltype(std::ranges::iter_move(std::declval<it_t &>()));
103 };
104 
105 // see specialisation for ranges in core/metafunction/range.hpp
106 
107 // ----------------------------------------------------------------------------
108 // const_reference
109 // ----------------------------------------------------------------------------
110 
111 // only defined for ranges
112 
113 // ----------------------------------------------------------------------------
114 // difference_type
115 // ----------------------------------------------------------------------------
116 
120 template <std::WeaklyIncrementable it_t>
121 struct difference_type<it_t>
122 {
124  using type = typename std::iterator_traits<std::remove_reference_t<it_t>>::difference_type;
125 };
126 
127 // see specialisation for ranges in core/metafunction/range.hpp
128 
129 // ----------------------------------------------------------------------------
130 // size_type
131 // ----------------------------------------------------------------------------
132 
136 template <std::WeaklyIncrementable it_t>
137 struct size_type<it_t>
138 {
140  using type = std::make_unsigned_t<difference_type_t<it_t>>;
141 };
142 
143 // see specialisation for ranges in core/metafunction/range.hpp
144 
146 
147 } // namespace seqan3
Contains platform and dependency checks.
Provides C++20 additions to the <iterator> header.
std::make_unsigned_t< difference_type_t< it_t > > type
Return the member type as return type.
Definition: iterator.hpp:140
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
decltype(std::ranges::iter_move(std::declval< it_t & >())) type
Return the member type as return type.
Definition: iterator.hpp:102
Type metafunction that returns the difference_type of another type [metafunction declaration].
Definition: pre.hpp:172
Provides various metafunctions base templates and shortcuts.
Adaptations of concepts from the Ranges TS.
Type metafunction that returns the size_type of another type [metafunction declaration].
Definition: pre.hpp:198
Provides C++20 additions to the type_traits header.
typename std::iterator_traits< std::remove_reference_t< it_t > >::reference type
Return the member type as return type.
Definition: iterator.hpp:86
Type metafunction that returns the rvalue_reference of another type [metafunction declaration]...
Definition: pre.hpp:118
Type metafunction that returns the reference of another type [metafunction declaration].
Definition: pre.hpp:92
typename std::iterator_traits< std::remove_reference_t< it_t > >::difference_type type
Return the member type as return type.
Definition: iterator.hpp:124
Type metafunction that returns the value_type of another type [metafunction declaration].
Definition: pre.hpp:66
typename std::iterator_traits< std::remove_reference_t< it_t > >::value_type type
Return the member type as return type.
Definition: iterator.hpp:70
::ranges::iter_move iter_move
Alias for ranges::iter_move. Casts the result of dereferencing an object to its associated rvalue ref...
Definition: ranges:265