Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
replace.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_REPLACE_HPP
9#define ADOBE_ALGORITHM_REPLACE_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15
16#include <algorithm>
17#include <functional>
18
19/**************************************************************************************************/
20
21namespace adobe {
22
23/**************************************************************************************************/
34/**************************************************************************************************/
40template <class ForwardRange, class T>
41inline void replace(ForwardRange& range, const T& old_value, const T& new_value) {
42 std::replace(boost::begin(range), boost::end(range), old_value, new_value);
43}
44
50template <class ForwardIterator, class Predicate, class T>
51inline void replace_if(ForwardIterator first, ForwardIterator last, Predicate pred,
52 const T& new_value) {
53 std::replace_if(first, last, std::bind(pred, std::placeholders::_1), new_value);
54}
55
61template <class ForwardRange, class Predicate, class T>
62inline void replace_if(ForwardRange& range, Predicate pred, const T& new_value) {
63 adobe::replace_if(boost::begin(range), boost::end(range), pred, new_value);
64}
65
71template <class ForwardRange, class OutputIterator, class T>
72inline OutputIterator replace_copy(ForwardRange& range, OutputIterator result, const T& old_value,
73 const T& new_value) {
74 return std::replace_copy(boost::begin(range), boost::end(range), result, old_value, new_value);
75}
76
82template <class ForwardRange, class OutputIterator, class T>
83inline OutputIterator replace_copy(const ForwardRange& range, OutputIterator result,
84 const T& old_value, const T& new_value) {
85 return std::replace_copy(boost::begin(range), boost::end(range), result, old_value, new_value);
86}
87
93template <class ForwardIterator, class OutputIterator, class Predicate, class T>
94inline OutputIterator replace_copy_if(ForwardIterator first, ForwardIterator last,
95 OutputIterator result, Predicate pred, const T& new_value) {
96 return std::replace_copy_if(first, last, result, std::bind(pred, std::placeholders::_1),
97 new_value);
98}
99
105template <class ForwardRange, class OutputIterator, class Predicate, class T>
106inline OutputIterator replace_copy_if(ForwardRange& range, OutputIterator result, Predicate pred,
107 const T& new_value) {
108 return adobe::replace_copy_if(boost::begin(range), boost::end(range), result, pred, new_value);
109}
110
116template <class ForwardRange, class OutputIterator, class Predicate, class T>
117inline OutputIterator replace_copy_if(const ForwardRange& range, OutputIterator result,
118 Predicate pred, const T& new_value) {
119 return adobe::replace_copy_if(boost::begin(range), boost::end(range), result, pred, new_value);
120}
121
122/**************************************************************************************************/
123
124} // namespace adobe
125
126/**************************************************************************************************/
127
128#endif
129
130/**************************************************************************************************/
OutputIterator replace_copy_if(ForwardIterator first, ForwardIterator last, OutputIterator result, Predicate pred, const T &new_value)
replace implementation
Definition replace.hpp:94
void replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T &new_value)
replace implementation
Definition replace.hpp:51
OutputIterator replace_copy(ForwardRange &range, OutputIterator result, const T &old_value, const T &new_value)
replace implementation
Definition replace.hpp:72
void replace(ForwardRange &range, const T &old_value, const T &new_value)
replace implementation
Definition replace.hpp:41