Mail Archives: djgpp/2000/11/02/06:45:13
Steamer wrote:
> > > The code that Stan Moore posted obviously won't work with most C++
> > > compilers.
> >
> >
> > Well its not so obvious to me.:)
> > Let me see if I got this straight
> > He's using this form of compare:
> > if (( pos3 > 0 ) && (word.compare(ies, pos3)))
> >
> > which would match:
> > int compare(const basic_string& str, size_type n1,)
> >
> > Which does not match any compare() function in standard c++ but is
> > included with djgpp.
> >
> > Correct ?
>
> Correct.
Ok Thanks for setting me straight.
Now Ive got a similar problem with replace() and I don't know if this is
the same situation. How do I tell if my function is not supported ? I'd
like to be able to know, because if it is supported, the error is
probably mine.
This is based on the example on page 1173 pf c++ Primer by Lippman and
Lajoie, a reliable text.
#include <string>
#include <algorithm>
int main()
{
string str = "The rain in Spain falls mainly on the plain\n";
cout << "string:"<< str;
string oldval = "rain";
string newval = "sleet";
replace (str.begin(), str.end(), oldval, newval) ;
cout << "new str:"<< str;
}
I get these messages:
c:/djgpp/lang/cxx/stl_algo.h: In function `void replace<char *,
string>(char *, char *, const string &, const string &)':
replace.cpp:11: instantiated from here
c:/djgpp/lang/cxx/stl_algo.h:471: no match for `char & == const
basic_string<char,string_char_traits<char>,__default_alloc_template<false,0>
> &'
c:/djgpp/lang/cxx/stl_algo.h:472: `const class
basic_string<char,string_char_traits<char>,__default_alloc_template<false,0>
>' used where a `char' was expected
- Raw text -