Skip to content

Commit 23a625a

Browse files
committed
Add lifetime annotations to cppsort::utility::metrics
1 parent 4f8c43c commit 23a625a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

include/cpp-sort/utility/metrics_tools.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <tuple>
1313
#include <type_traits>
1414
#include <utility>
15+
#include "../detail/config.h"
1516
#include "../detail/type_traits.h"
1617

1718
namespace cppsort::utility
@@ -70,6 +71,7 @@ namespace cppsort::utility
7071

7172
constexpr auto operator=(const T& other)
7273
noexcept(std::is_nothrow_copy_assignable_v<T>)
74+
CPPSORT_LIFETIME_BOUND
7375
-> metric&
7476
{
7577
_value = other;
@@ -78,6 +80,7 @@ namespace cppsort::utility
7880

7981
constexpr auto operator=(T&& other)
8082
noexcept(std::is_nothrow_move_assignable_v<T>)
83+
CPPSORT_LIFETIME_BOUND
8184
-> metric&
8285
{
8386
_value = std::move(other);
@@ -87,6 +90,7 @@ namespace cppsort::utility
8790
template<typename U>
8891
constexpr auto operator=(const metric<U, Tag>& other)
8992
noexcept(std::is_nothrow_assignable_v<T&, const U&>)
93+
CPPSORT_LIFETIME_BOUND
9094
-> metric&
9195
{
9296
_value = other._value;
@@ -96,6 +100,7 @@ namespace cppsort::utility
96100
template<typename U>
97101
constexpr auto operator=(metric<U, Tag>&& other)
98102
noexcept(std::is_nothrow_assignable_v<T&, U>)
103+
CPPSORT_LIFETIME_BOUND
99104
-> metric&
100105
{
101106
_value = std::move(other._value);
@@ -271,28 +276,28 @@ namespace cppsort::utility
271276
// Index-based get()
272277

273278
template<std::size_t Idx>
274-
friend constexpr auto get(metrics& mm)
279+
friend constexpr auto get(metrics& mm CPPSORT_LIFETIME_BOUND)
275280
-> std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&
276281
{
277282
return std::get<Idx>(mm.metrics_);
278283
}
279284

280285
template<std::size_t Idx>
281-
friend constexpr auto get(const metrics& mm)
286+
friend constexpr auto get(const metrics& mm CPPSORT_LIFETIME_BOUND)
282287
-> const std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&
283288
{
284289
return std::get<Idx>(mm.metrics_);
285290
}
286291

287292
template<std::size_t Idx>
288-
friend constexpr auto get(metrics&& mm)
293+
friend constexpr auto get(metrics&& mm CPPSORT_LIFETIME_BOUND)
289294
-> std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&&
290295
{
291296
return std::get<Idx>(std::move(mm).metrics_);
292297
}
293298

294299
template<std::size_t Idx>
295-
friend constexpr auto get(const metrics&& mm)
300+
friend constexpr auto get(const metrics&& mm CPPSORT_LIFETIME_BOUND)
296301
-> const std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&&
297302
{
298303
return std::get<Idx>(std::move(mm).metrics_);
@@ -302,28 +307,28 @@ namespace cppsort::utility
302307
// Tag-based get()
303308

304309
template<typename Tag, std::size_t Idx=cppsort::detail::index_of<Tag, Tags...>>
305-
friend constexpr auto get(metrics& mm)
310+
friend constexpr auto get(metrics& mm CPPSORT_LIFETIME_BOUND)
306311
-> std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&
307312
{
308313
return std::get<Idx>(mm.metrics_);
309314
}
310315

311316
template<typename Tag, std::size_t Idx=cppsort::detail::index_of<Tag, Tags...>>
312-
friend constexpr auto get(const metrics& mm)
317+
friend constexpr auto get(const metrics& mm CPPSORT_LIFETIME_BOUND)
313318
-> const std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&
314319
{
315320
return std::get<Idx>(mm.metrics_);
316321
}
317322

318323
template<typename Tag, std::size_t Idx=cppsort::detail::index_of<Tag, Tags...>>
319-
friend constexpr auto get(metrics&& mm)
324+
friend constexpr auto get(metrics&& mm CPPSORT_LIFETIME_BOUND)
320325
-> std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&&
321326
{
322327
return std::get<Idx>(std::move(mm).metrics_);
323328
}
324329

325330
template<typename Tag, std::size_t Idx=cppsort::detail::index_of<Tag, Tags...>>
326-
friend constexpr auto get(const metrics&& mm)
331+
friend constexpr auto get(const metrics&& mm CPPSORT_LIFETIME_BOUND)
327332
-> const std::tuple_element_t<Idx, std::tuple<metric<TT, Tags>...>>&&
328333
{
329334
return std::get<Idx>(std::move(mm).metrics_);

0 commit comments

Comments
 (0)