Skip to content

Commit fcf3b33

Browse files
Improve return type of MyFoldLeftFirst (#303)
1 parent 68424af commit fcf3b33

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

solvers/cpp/src/lib/my_fold_left_first.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class MyFoldLeftFirstFunction {
1919
public:
2020
template <std::input_iterator I, std::sentinel_for<I> S, typename Fn>
2121
constexpr auto operator()(I first, const S& last, Fn fn) const {
22-
using RetVal = typename std::iterator_traits<decltype(first)>::value_type;
22+
using InitVal = std::iter_value_t<I>;
23+
using RetVal =
24+
std::invoke_result_t<decltype(std::ranges::fold_left), I, S, InitVal, Fn>;
2325

2426
if (first == last) {
2527
return std::optional<RetVal>();

0 commit comments

Comments
 (0)