Skip to content

Commit 393ac87

Browse files
committed
Add more lifetime annotations
1 parent eb88584 commit 393ac87

File tree

9 files changed

+30
-3
lines changed

9 files changed

+30
-3
lines changed

include/cpp-sort/detail/associate_iterator.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <iterator>
1212
#include <utility>
1313
#include <cpp-sort/utility/iter_move.h>
14+
#include "config.h"
1415
#include "iterator_traits.h"
1516

1617
namespace cppsort::detail
@@ -62,6 +63,7 @@ namespace cppsort::detail
6263
{}
6364

6465
auto operator=(association&& other) noexcept
66+
CPPSORT_LIFETIME_BOUND
6567
-> association&
6668
{
6769
*it = std::move(*other.it);
@@ -70,6 +72,7 @@ namespace cppsort::detail
7072
}
7173

7274
auto operator=(associated_value<value_type_t<Iterator>, Data>&& other)
75+
CPPSORT_LIFETIME_BOUND
7376
-> association&
7477
{
7578
*it = std::move(other.value);
@@ -124,6 +127,7 @@ namespace cppsort::detail
124127
{}
125128

126129
auto operator=(associated_value&& other)
130+
CPPSORT_LIFETIME_BOUND
127131
-> associated_value&
128132
{
129133
value = std::move(other.value);
@@ -133,13 +137,15 @@ namespace cppsort::detail
133137

134138
[[nodiscard]]
135139
auto get()
140+
CPPSORT_LIFETIME_BOUND
136141
-> Value&
137142
{
138143
return value;
139144
}
140145

141146
[[nodiscard]]
142147
auto get() const
148+
CPPSORT_LIFETIME_BOUND
143149
-> const Value&
144150
{
145151
return value;
@@ -207,27 +213,31 @@ namespace cppsort::detail
207213
// Increment/decrement operators
208214

209215
auto operator++()
216+
CPPSORT_LIFETIME_BOUND
210217
-> associate_iterator&
211218
{
212219
++_it;
213220
return *this;
214221
}
215222

216223
auto operator--()
224+
CPPSORT_LIFETIME_BOUND
217225
-> associate_iterator&
218226
{
219227
--_it;
220228
return *this;
221229
}
222230

223231
auto operator+=(difference_type increment)
232+
CPPSORT_LIFETIME_BOUND
224233
-> associate_iterator&
225234
{
226235
_it += increment;
227236
return *this;
228237
}
229238

230239
auto operator-=(difference_type increment)
240+
CPPSORT_LIFETIME_BOUND
231241
-> associate_iterator&
232242
{
233243
_it -= increment;

include/cpp-sort/detail/fake_category_iterator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <type_traits>
1313
#include <utility>
1414
#include <cpp-sort/utility/iter_move.h>
15+
#include "config.h"
1516
#include "iterator_traits.h"
1617
#include "type_traits.h"
1718

@@ -84,6 +85,7 @@ namespace cppsort::detail
8485
// Increment/decrement operators
8586

8687
auto operator++()
88+
CPPSORT_LIFETIME_BOUND
8789
-> fake_category_iterator&
8890
{
8991
++_it;
@@ -99,6 +101,7 @@ namespace cppsort::detail
99101
}
100102

101103
auto operator--()
104+
CPPSORT_LIFETIME_BOUND
102105
-> fake_category_iterator&
103106
{
104107
--_it;
@@ -114,13 +117,15 @@ namespace cppsort::detail
114117
}
115118

116119
auto operator+=(difference_type increment)
120+
CPPSORT_LIFETIME_BOUND
117121
-> fake_category_iterator&
118122
{
119123
_it += increment;
120124
return *this;
121125
}
122126

123127
auto operator-=(difference_type increment)
128+
CPPSORT_LIFETIME_BOUND
124129
-> fake_category_iterator&
125130
{
126131
_it -= increment;

include/cpp-sort/detail/fixed_size_list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ namespace cppsort::detail
308308
// Increment/decrement operators
309309

310310
auto operator++() noexcept
311+
CPPSORT_LIFETIME_BOUND
311312
-> fixed_size_list_iterator&
312313
{
313314
ptr_ = ptr_->next;
@@ -323,6 +324,7 @@ namespace cppsort::detail
323324
}
324325

325326
auto operator--() noexcept
327+
CPPSORT_LIFETIME_BOUND
326328
-> fixed_size_list_iterator&
327329
{
328330
ptr_ = ptr_->prev;

include/cpp-sort/detail/memory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <new>
2424
#include <type_traits>
2525
#include <utility>
26+
#include "config.h"
2627
#include "type_traits.h"
2728

2829
namespace cppsort::detail
@@ -201,6 +202,7 @@ namespace cppsort::detail
201202
temporary_buffer& operator=(const temporary_buffer&) = delete;
202203

203204
auto operator=(temporary_buffer&& other) noexcept
205+
CPPSORT_LIFETIME_BOUND
204206
-> temporary_buffer&
205207
{
206208
using std::swap;

include/cpp-sort/detail/merge_insertion_sort.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <cpp-sort/utility/as_function.h>
1414
#include <cpp-sort/utility/functional.h>
1515
#include <cpp-sort/utility/iter_move.h>
16+
#include "config.h"
1617
#include "fixed_size_list.h"
1718
#include "immovable_vector.h"
1819
#include "iterator_traits.h"
@@ -90,27 +91,31 @@ namespace cppsort::detail
9091
// Increment/decrement operators
9192

9293
auto operator++()
94+
CPPSORT_LIFETIME_BOUND
9395
-> group_iterator&
9496
{
9597
std::advance(_it, _size);
9698
return *this;
9799
}
98100

99101
auto operator--()
102+
CPPSORT_LIFETIME_BOUND
100103
-> group_iterator&
101104
{
102105
std::advance(_it, -_size);
103106
return *this;
104107
}
105108

106109
auto operator+=(difference_type increment)
110+
CPPSORT_LIFETIME_BOUND
107111
-> group_iterator&
108112
{
109113
_it += _size * increment;
110114
return *this;
111115
}
112116

113117
auto operator-=(difference_type increment)
118+
CPPSORT_LIFETIME_BOUND
114119
-> group_iterator&
115120
{
116121
_it -= _size * increment;

include/cpp-sort/detail/ska_sort.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <utility>
2424
#include <cpp-sort/utility/as_function.h>
2525
#include <cpp-sort/utility/iter_move.h>
26+
#include "config.h"
2627
#include "iterator_traits.h" // projected_t
2728
#include "memcpy_cast.h"
2829
#include "partition.h"
@@ -460,7 +461,7 @@ namespace cppsort::detail
460461
using next = SubKey<void>;
461462
using sub_key_type = T;
462463

463-
static auto sub_key(const T& value, void*)
464+
static auto sub_key(const T& value CPPSORT_LIFETIME_BOUND, void*)
464465
-> const T&
465466
{
466467
return value;

include/cpp-sort/metrics/moves.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <cpp-sort/utility/metrics_tools.h>
1919
#include <cpp-sort/utility/size.h>
2020
#include "../detail/checkers.h"
21+
#include "../detail/config.h"
2122
#include "../detail/fake_category_iterator.h"
2223
#include "../detail/immovable_vector.h"
2324
#include "../detail/iterator_traits.h"
@@ -50,6 +51,7 @@ namespace cppsort::metrics
5051
}
5152

5253
auto operator=(move_counting_wrapper&& other)
54+
CPPSORT_LIFETIME_BOUND
5355
-> move_counting_wrapper&
5456
{
5557
value = std::move(other.value);

include/cpp-sort/utility/functional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ namespace cppsort::utility
137137
projection_base<identity>
138138
{
139139
template<typename T>
140-
constexpr auto operator()(T&& value) const noexcept
140+
constexpr auto operator()(T&& value CPPSORT_LIFETIME_BOUND) const noexcept
141141
-> T&&
142142
{
143143
return std::forward<T>(value);

include/cpp-sort/utility/metrics_tools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ namespace cppsort::utility
231231
// Stream operators
232232

233233
template<typename U=T>
234-
friend auto operator<<(std::ostream& stream, const metric& met)
234+
friend auto operator<<(std::ostream& stream CPPSORT_LIFETIME_BOUND, const metric& met)
235235
-> decltype(stream << std::declval<U&>())
236236
{
237237
stream << met.value();

0 commit comments

Comments
 (0)