string literal does not match array template parameter

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top