diff --git a/include/flux/op/fold.hpp b/include/flux/op/fold.hpp index c42a7c40..3d839d63 100644 --- a/include/flux/op/fold.hpp +++ b/include/flux/op/fold.hpp @@ -65,7 +65,11 @@ struct sum_op { [[nodiscard]] constexpr auto operator()(Seq&& seq) const -> value_t { - return fold_op{}(FLUX_FWD(seq), std::plus<>{}, value_t(0)); + if constexpr (num::integral>) { + return fold_op{}(FLUX_FWD(seq), num::add, value_t(0)); + } else { + return fold_op{}(FLUX_FWD(seq), std::plus<>{}, value_t(0)); + } } }; @@ -76,7 +80,11 @@ struct product_op { [[nodiscard]] constexpr auto operator()(Seq&& seq) const -> value_t { - return fold_op{}(FLUX_FWD(seq), std::multiplies<>{}, value_t(1)); + if constexpr (num::integral>) { + return fold_op{}(FLUX_FWD(seq), num::mul, value_t(1)); + } else { + return fold_op{}(FLUX_FWD(seq), std::multiplies<>{}, value_t(1)); + } } };