string literal does not match array template parameter

Discussion in 'C++' started by Old Wolf, Mar 14, 2005.

  1. Old Wolf

    Old Wolf Guest

    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?
    Old Wolf, Mar 14, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    733
    Frank Schmitt
    Sep 22, 2003
  2. blueblueblue2005
    Replies:
    6
    Views:
    998
    blueblueblue2005
    Jul 19, 2005
  3. Alex Buell
    Replies:
    2
    Views:
    651
    Alex Buell
    Feb 21, 2006
  4. Joseph Turian
    Replies:
    2
    Views:
    848
    Joseph Turian
    Mar 22, 2007
  5. abir
    Replies:
    4
    Views:
    397
Loading...

Share This Page