/*============================================================================= Copyright (c) 2011-2018 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_NUMERIC_REDUCE_HPP #define SPROUT_NUMERIC_REDUCE_HPP #include #include #include #include namespace sprout { // // reduce // // recursion depth: // O(log N) // template inline SPROUT_CONSTEXPR typename std::iterator_traits::value_type reduce(InputIterator first, InputIterator last) { return sprout::accumulate(first, last, typename std::iterator_traits::value_type()); } template inline SPROUT_CONSTEXPR T reduce(InputIterator first, InputIterator last, T init) { return sprout::accumulate(first, last, init); } template inline SPROUT_CONSTEXPR T reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) { return sprout::accumulate(first, last, init, binary_op); } } // namespace sprout #endif // #ifndef SPROUT_NUMERIC_REDUCE_HPP