diff --git a/sprout/algorithm/copy.hpp b/sprout/algorithm/copy.hpp index eb158687..acc23abf 100644 --- a/sprout/algorithm/copy.hpp +++ b/sprout/algorithm/copy.hpp @@ -9,10 +9,8 @@ #define SPROUT_ALGORITHM_COPY_HPP #include -#include #include -#include -#include +#include namespace sprout { // @@ -29,21 +27,6 @@ namespace sprout { } return result; } - - template< - typename InputIterator, typename Result, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy(InputIterator first, InputIterator last, Result const& result) { - return sprout::fixed::copy(first, last, result); - } - - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy(InputIterator first, InputIterator last) { - return sprout::fixed::copy(first, last); - } } // namespace sprout #include diff --git a/sprout/algorithm/copy_backward.hpp b/sprout/algorithm/copy_backward.hpp index c2ce8a6f..67f9a5df 100644 --- a/sprout/algorithm/copy_backward.hpp +++ b/sprout/algorithm/copy_backward.hpp @@ -9,10 +9,8 @@ #define SPROUT_ALGORITHM_COPY_BACKWARD_HPP #include -#include #include -#include -#include +#include namespace sprout { // @@ -29,21 +27,6 @@ namespace sprout { } return result; } - - template< - typename BidirectionalIterator, typename Result, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_backward(BidirectionalIterator first, BidirectionalIterator last, Result const& result) { - return sprout::fixed::copy_backward(first, last, result); - } - - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_backward(BidirectionalIterator first, BidirectionalIterator last) { - return sprout::fixed::copy_backward(first, last); - } } // namespace sprout #include diff --git a/sprout/algorithm/copy_if.hpp b/sprout/algorithm/copy_if.hpp index b5755da9..9924ddaa 100644 --- a/sprout/algorithm/copy_if.hpp +++ b/sprout/algorithm/copy_if.hpp @@ -9,10 +9,8 @@ #define SPROUT_ALGORITHM_COPY_IF_HPP #include -#include #include -#include -#include +#include namespace sprout { // @@ -31,21 +29,6 @@ namespace sprout { } return result; } - - template< - typename InputIterator, typename Result, typename Predicate, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred) { - return sprout::fixed::copy_if(first, last, result, pred); - } - - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_if(InputIterator first, InputIterator last, Predicate pred) { - return sprout::fixed::copy_if(first, last, pred); - } } // namespace sprout #include diff --git a/sprout/algorithm/copy_n.hpp b/sprout/algorithm/copy_n.hpp index 86c415e8..8d6326c9 100644 --- a/sprout/algorithm/copy_n.hpp +++ b/sprout/algorithm/copy_n.hpp @@ -9,10 +9,8 @@ #define SPROUT_ALGORITHM_COPY_N_HPP #include -#include #include -#include -#include +#include namespace sprout { // @@ -29,21 +27,6 @@ namespace sprout { } return result; } - - template< - typename InputIterator, typename Size, typename Result, - typename sprout::enabler_if::value>::type = sprout::enabler - > - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_n(InputIterator first, Size n, Result const& result) { - return sprout::fixed::copy_n(first, n, result); - } - - template - inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type - copy_n(InputIterator first, Size n) { - return sprout::fixed::copy_n(first, n); - } } // namespace sprout #include diff --git a/sprout/algorithm/fixed/copy.hpp b/sprout/algorithm/fixed/copy.hpp index 8045c483..fa637479 100644 --- a/sprout/algorithm/fixed/copy.hpp +++ b/sprout/algorithm/fixed/copy.hpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -134,6 +136,21 @@ namespace sprout { return sprout::fixed::copy(first, last, sprout::pit()); } } // namespace fixed + + template< + typename InputIterator, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy(InputIterator first, InputIterator last, Result const& result) { + return sprout::fixed::copy(first, last, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy(InputIterator first, InputIterator last) { + return sprout::fixed::copy(first, last); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_HPP diff --git a/sprout/algorithm/fixed/copy_backward.hpp b/sprout/algorithm/fixed/copy_backward.hpp index 5603f685..a0e070bb 100644 --- a/sprout/algorithm/fixed/copy_backward.hpp +++ b/sprout/algorithm/fixed/copy_backward.hpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -124,6 +126,21 @@ namespace sprout { return sprout::fixed::copy_backward(first, last, sprout::pit()); } } // namespace fixed + + template< + typename BidirectionalIterator, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_backward(BidirectionalIterator first, BidirectionalIterator last, Result const& result) { + return sprout::fixed::copy_backward(first, last, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_backward(BidirectionalIterator first, BidirectionalIterator last) { + return sprout::fixed::copy_backward(first, last); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_BACKWARD_HPP diff --git a/sprout/algorithm/fixed/copy_if.hpp b/sprout/algorithm/fixed/copy_if.hpp index 4ca0cf88..2a3fd59f 100644 --- a/sprout/algorithm/fixed/copy_if.hpp +++ b/sprout/algorithm/fixed/copy_if.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -89,6 +91,21 @@ namespace sprout { return sprout::fixed::copy_if(first, last, sprout::pit(), pred); } } // namespace fixed + + template< + typename InputIterator, typename Result, typename Predicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + return sprout::fixed::copy_if(first, last, result, pred); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_if(InputIterator first, InputIterator last, Predicate pred) { + return sprout::fixed::copy_if(first, last, pred); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_IF_HPP diff --git a/sprout/algorithm/fixed/copy_n.hpp b/sprout/algorithm/fixed/copy_n.hpp index ae3c1711..d325b59a 100644 --- a/sprout/algorithm/fixed/copy_n.hpp +++ b/sprout/algorithm/fixed/copy_n.hpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -107,6 +109,21 @@ namespace sprout { return sprout::fixed::copy_n(first, n, sprout::pit()); } } // namespace fixed + + template< + typename InputIterator, typename Size, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_n(InputIterator first, Size n, Result const& result) { + return sprout::fixed::copy_n(first, n, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_n(InputIterator first, Size n) { + return sprout::fixed::copy_n(first, n); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_N_HPP diff --git a/sprout/algorithm/fixed/transform.hpp b/sprout/algorithm/fixed/transform.hpp index e120f0d9..536553ce 100644 --- a/sprout/algorithm/fixed/transform.hpp +++ b/sprout/algorithm/fixed/transform.hpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -260,7 +262,39 @@ namespace sprout { } } // namespace fixed - using sprout::fixed::transform; + template< + typename InputIterator, typename Result, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + transform(InputIterator first, InputIterator last, Result const& result, UnaryOperation op) { + return sprout::fixed::transform(first, last, result, op); + } + template< + typename Result, typename InputIterator, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + transform(InputIterator first, InputIterator last, UnaryOperation op) { + return sprout::fixed::transform(first, last, op); + } + + template< + typename InputIterator1, typename InputIterator2, typename Result, typename BinaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Result const& result, BinaryOperation op) { + return sprout::fixed::transform(first1, last1, first2, result, op); + } + template< + typename Result, typename InputIterator1, typename InputIterator2, typename BinaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperation op) { + return sprout::fixed::transform(first1, last1, first2, op); + } } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_TRANSFORM_HPP diff --git a/sprout/algorithm/replace.hpp b/sprout/algorithm/replace.hpp index 7846ac27..ca196c25 100644 --- a/sprout/algorithm/replace.hpp +++ b/sprout/algorithm/replace.hpp @@ -9,6 +9,22 @@ #define SPROUT_ALGORITHM_REPLACE_HPP #include + +namespace sprout { + // + // 25.3.5 Replace + // + template + inline SPROUT_CXX14_CONSTEXPR void + replace(ForwrdIterator first, ForwrdIterator last, T const& old_value, T const& new_value) { + for (; first != last; ++first) { + if (*first == old_value) { + *first = new_value; + } + } + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/transform.hpp b/sprout/algorithm/transform.hpp index 81548f59..ff93c0b1 100644 --- a/sprout/algorithm/transform.hpp +++ b/sprout/algorithm/transform.hpp @@ -9,6 +9,37 @@ #define SPROUT_ALGORITHM_TRANSFORM_HPP #include +#include +#include + +namespace sprout { + // + // 25.3.4 Transform + // + template< + typename InputIterator, typename OutputIterator, typename UnaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op) { + while (first != last) { + *result++ = op(*first++); + } + return result; + } + template< + typename InputIterator1, typename InputIterator2, typename OutputIterator, typename BinaryOperation, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryOperation op) { + while (first1 != last1) { + *result++ = op(*first1++, *first2++); + } + return result; + } +} // namespace sprout + #include #include