mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +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,22 @@
|
|||
#define SPROUT_ALGORITHM_REPLACE_IF_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.3.5 Replace
|
||||
//
|
||||
template<typename ForwrdIterator, typename Predicate, typename T>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
replace_if(ForwrdIterator first, ForwrdIterator last, Predicate pred, T const& new_value) {
|
||||
for (; first != last; ++first) {
|
||||
if (pred(*first)) {
|
||||
*first = new_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/algorithm/fixed/replace_if.hpp>
|
||||
#include <sprout/algorithm/fit/replace_if.hpp>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue