Skip to content

Commit caed9cc

Browse files
committed
Fix ambiguous overload issue with Clang
1 parent 5b39a91 commit caed9cc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/cpp-sort/sorter_facade.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,24 @@ namespace cppsort
14051405
}
14061406
};
14071407

1408+
namespace detail
1409+
{
1410+
template<typename Iterator, typename... Args>
1411+
inline constexpr bool are_parameters_valid = false;
1412+
1413+
template<typename Iterator>
1414+
inline constexpr bool are_parameters_valid<Iterator> = true;
1415+
1416+
template<typename Iterator, typename Func>
1417+
inline constexpr bool are_parameters_valid<Iterator, Func>
1418+
= is_projection_iterator_v<std::identity, Iterator, Func> ||
1419+
is_projection_iterator_v<Func, Iterator, std::less<>>;
1420+
1421+
template<typename Iterator, typename Compare, typename Projection>
1422+
inline constexpr bool are_parameters_valid<Iterator, Compare, Projection>
1423+
= is_projection_iterator_v<Projection, Iterator, Compare>;
1424+
}
1425+
14081426
template<typename Sorter>
14091427
struct sorter_facade:
14101428
sorter_facade_base<Sorter>
@@ -1418,6 +1436,7 @@ namespace cppsort
14181436
typename... Args
14191437
>
14201438
requires mstd::permutable<Iterator>
1439+
&& detail::are_parameters_valid<Iterator, Args...>
14211440
constexpr auto operator()(this Self&& self, Iterator first, Sentinel last, Args&&... args)
14221441
-> decltype(std::forward<Self>(self).sorter_facade_base<Sorter>::operator()(
14231442
std::move(first), std::move(last), std::forward<Args>(args)...
@@ -1434,6 +1453,7 @@ namespace cppsort
14341453
typename... Args
14351454
>
14361455
requires mstd::permutable<mstd::iterator_t<Range>>
1456+
&& detail::are_parameters_valid<mstd::iterator_t<Range>, Args...>
14371457
constexpr auto operator()(this Self&& self, Range&& range, Args&&... args)
14381458
-> decltype(std::forward<Self>(self).sorter_facade_base<Sorter>::operator()(
14391459
std::forward<Range>(range), std::forward<Args>(args)...

0 commit comments

Comments
 (0)