mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-14 15:04:09 +00:00
add c++14 constexpr version: fill, fill_n
This commit is contained in:
parent
3f85600f53
commit
7b11799ace
11 changed files with 152 additions and 17 deletions
|
@ -9,6 +9,26 @@
|
|||
#define SPROUT_ALGORITHM_REPLACE_COPY_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.3.5 Replace
|
||||
//
|
||||
template<
|
||||
typename InputIterator, typename OutputIterator, typename T,
|
||||
typename sprout::enabler_if<sprout::is_output_iterator<OutputIterator>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
replace_copy(InputIterator first, InputIterator last, OutputIterator result, T const& old_value, T const& new_value) {
|
||||
for (; first != last; ++first) {
|
||||
*result++ = (*first == old_value ? new_value : *first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/algorithm/fixed/replace_copy.hpp>
|
||||
#include <sprout/algorithm/fit/replace_copy.hpp>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue