Skip to content

Commit 4d80f18

Browse files
committed
Constraint fixed_size_list functions taking a callable
The push_front/push_back overloads that accept a callable are too greedy: they are preferred over the ones taking a value_type even when a conversion is expected - and subsequently fail to compile. This commit constrains them with std::invocable to make them much less greedy.
1 parent 9bb7773 commit 4d80f18

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/cpp-sort/detail/fixed_size_list.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2023 Morwenn
2+
* Copyright (c) 2020-2024 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_DETAIL_FIXED_SIZE_LIST_H_
@@ -8,6 +8,7 @@
88
////////////////////////////////////////////////////////////
99
// Headers
1010
////////////////////////////////////////////////////////////
11+
#include <concepts>
1112
#include <cstddef>
1213
#include <iterator>
1314
#include <memory>
@@ -559,7 +560,7 @@ namespace cppsort::detail
559560
insert_node_(&sentinel_node_, std::move(value));
560561
}
561562

562-
template<typename Callable>
563+
template<std::invocable<node_type*> Callable>
563564
auto push_back(Callable&& setter)
564565
-> void
565566
{
@@ -578,7 +579,7 @@ namespace cppsort::detail
578579
insert_node_(sentinel_node_.next, std::move(value));
579580
}
580581

581-
template<typename Callable>
582+
template<std::invocable<node_type*> Callable>
582583
auto push_front(Callable&& setter)
583584
-> void
584585
{
@@ -797,7 +798,7 @@ namespace cppsort::detail
797798
return new_node;
798799
}
799800

800-
template<typename Callable>
801+
template<std::invocable<node_type*> Callable>
801802
auto insert_node_(list_node_base* pos, Callable setter)
802803
-> node_type*
803804
{

0 commit comments

Comments
 (0)