Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
converterCommon.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace convert {
9
10inline auto replaceInplace = [] ( std::string & str, const std::string & what, const std::string & with ) {
11 size_t index = 0;
12
13 while ( ( index = str.find ( what, index ) ) != std::string::npos ) {
14 str.replace ( index, what.length ( ), with );
15 index += with.length ( );
16 }
17};
18
19inline auto replace = [] ( std::string str, const std::string & what, const std::string & with ) {
20 replaceInplace ( str, what, with );
21 return str;
22};
23
24} /* namespace convert */
25
Definition: converterCommon.hpp:8
auto replaceInplace
Definition: converterCommon.hpp:10
auto replace
Definition: converterCommon.hpp:19