Horje
c++ convert template function to normal function Code Example
c++ convert template function to normal function
#include <string>
#include <iostream>

using namespace std;

template<typename T>
void removeSubstrs(basic_string<T>& s,
                   const basic_string<T>& p) {
   basic_string<T>::size_type n = p.length();

   for (basic_string<T>::size_type i = s.find(p);
        i != basic_string<T>::npos;
        i = s.find(p))
      s.erase(i, n);
}

int main() {
   string s = "One fish, two fish, red fish, blue fish";
   string p = "fish";

   removeSubstrs(s, p);

   cout << s << '\n';
}
The basic_string member func




Cpp

Related
# in c++ Code Example # in c++ Code Example
1603. Design Parking System leetcode solution in c++ Code Example 1603. Design Parking System leetcode solution in c++ Code Example
getline int Code Example getline int Code Example
define a type in c++ Code Example define a type in c++ Code Example
input in c++ Code Example input in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7