std::replace
ΠΠΊΡΡΠ°Π»ΡΠ½ΠΎ Π΄Π»Ρ C++23.
#include <algorithm>
ΠΠΊΡΡΠ°Π»ΡΠ½ΠΎ Π½Π° 2024-03-20.
Define overload #1
template<class ForwardIterator, class T>
constexpr void
replace(ForwardIterator first, ForwardIterator last,
const T& old_value, const T& new_value);
ΠΠ°ΠΌΠ΅Π½ΡΠ΅Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ Π² Π΄ΠΈΠ°ΠΏΠ°Π·ΠΎΠ½Π΅ [first, last] ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΡΠ΅ old_value Π½Π° new_value.
ΠΠ»Π΅ΠΌΠ΅Π½ΡΡ ΡΡΠ°Π²Π½ΠΈΠ²Π°ΡΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ° "==".
Example, possible implementation
Define overload #2
template<class ExecutionPolicy, class ForwardIterator, class T>
void replace(ExecutionPolicy&& exec, orwardIterator first,
ForwardIterator last, const T& old_value, const T& new_value);
TODO
Example, possible implementation
Examples
Example 1:
#include <iostream>
#include <algorithm>
#include <string>
int main()
{
using namespace std;
using namespace std::string_literals;
auto s = "hello world!"s;
replace(std::begin(s), std::end(s), 'h', 'H');
std::cout << s << std::endl;
return 0;
}
Hello world!
Changelog
See also
TODO
This page was last modified on 2024-03-20