1 /* 2 Copyright (c) Marshall Clow 2017. 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 8 /// \file transform_exclusive_scan.hpp 9 /// \brief ???? 10 /// \author Marshall Clow 11 12 #ifndef BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP 13 #define BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP 14 15 #include <functional> // for std::plus 16 #include <iterator> // for std::iterator_traits 17 18 #include <boost/config.hpp> 19 #include <boost/range/begin.hpp> 20 #include <boost/range/end.hpp> 21 #include <boost/range/value_type.hpp> 22 23 namespace boost { namespace algorithm { 24 25 template<class InputIterator, class OutputIterator, class T, 26 class BinaryOperation, class UnaryOperation> 27 OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, 28 OutputIterator result, T init, 29 BinaryOperation bOp, UnaryOperation uOp) 30 { 31 if (first != last) 32 { 33 T saved = init; 34 do 35 { 36 init = bOp(init, uOp(*first)); 37 *result = saved; 38 saved = init; 39 ++result; 40 } while (++first != last); 41 } 42 return result; 43 } 44 45 }} // namespace boost and algorithm 46 47 #endif // BOOST_ALGORITHM_TRANSFORM_EXCLUSIVE_SCAN_HPP 48