File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ ones. `gfx::timsort` should be usable as a drop-in replacement for `std::stable_
1515can't fallback to a O(n log² n) algorithm when there isn't enough extra heap memory available.
1616
1717Additionally ` gfx::timsort ` can take a [ projection function] ( https://ezoeryou.github.io/blog/article/2019-01-22-ranges-projection.html )
18- after the comparison function. The support is a bit rougher than in the linked article or the C++20 stadard library:
19- only instances of types callable with parentheses can be used, there is no support for pointer to members.
18+ after the comparison function. The support is a bit rougher than in the linked article or the C++20 standard library:
19+ unless ` std::invoke ` is available, only instances of types callable with parentheses can be used, there is no support
20+ for pointer to members.
2021
2122This implementation of timsort notably avoids using the postfix ` ++ ` or ` -- ` operators: only their prefix equivalents
2223are used, which means that timsort will work even if the postfix operators are not present or return an incompatible
Original file line number Diff line number Diff line change @@ -133,10 +133,17 @@ struct projection_compare {
133133#if GFX_TIMSORT_USE_STD_MOVE
134134 template <typename T, typename U>
135135 bool operator ()(T &&lhs, U &&rhs) {
136+ # ifdef __cpp_lib_invoke
137+ return static_cast <bool >(std::invoke (compare,
138+ std::invoke (projection, std::forward<T>(lhs)),
139+ std::invoke (projection, std::forward<U>(rhs))
140+ ));
141+ # else
136142 return static_cast <bool >(compare (
137143 projection (std::forward<T>(lhs)),
138144 projection (std::forward<U>(rhs))
139145 ));
146+ # endif
140147 }
141148#else
142149 template <typename T, typename U>
You can’t perform that action at this time.
0 commit comments