O
Old Wolf
The purpose of the following code is to search a string for
a substring, and replace the first character of the found string
with a new value:
#include <algorithm>
#include <string>
template<typename InIt, typename CharT, int N>
void filter(InIt begin, InIt end, CharT const (&needle)[N], CharT
new_ch)
{
while (end != (begin = std::search(begin, end, needle, needle + N -
1)))
*begin++ = new_ch;
}
int main()
{
std::string s("bar");
filter(s.begin(), s.end(), "hi", 'H');
}
On GCC 3.4.1 it compiles correctly, but on BCC 5.5.1 I get the
error:
Could not find a match for filter<InIt,CharT,N>
(char *, char *, char *, char)
Is BCC wrong?
a substring, and replace the first character of the found string
with a new value:
#include <algorithm>
#include <string>
template<typename InIt, typename CharT, int N>
void filter(InIt begin, InIt end, CharT const (&needle)[N], CharT
new_ch)
{
while (end != (begin = std::search(begin, end, needle, needle + N -
1)))
*begin++ = new_ch;
}
int main()
{
std::string s("bar");
filter(s.begin(), s.end(), "hi", 'H');
}
On GCC 3.4.1 it compiles correctly, but on BCC 5.5.1 I get the
error:
Could not find a match for filter<InIt,CharT,N>
(char *, char *, char *, char)
Is BCC wrong?