Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7564

Re: rtrimws: can't compile in g++

From Miles Bader <miles@gnu.org>
Newsgroups comp.lang.c++
Subject Re: rtrimws: can't compile in g++
Date 2011-07-07 15:11 +0900
Organization NEC Electronics
Message-ID <buoipretybd.fsf@dhlpc061.dev.necel.com> (permalink)
References <1495ae9f-43f4-47bc-967f-18a6bb54e7b4@t7g2000vbv.googlegroups.com>

Show all headers | View raw


eric <cneric12lin0@gmail.com> writes:
> --------------------
> 4-4.cpp: In function ‘void rtrimws(std::string&)’:
> 4-4.cpp:21:21: error: too many arguments to function ‘void
> rtrimws(std::string&)’
> 4-4.cpp:20:6: note: declared here
> ------------

The problem seems to be that there are multiple overloaded versions of
"isspace"[*], and the compiler doesn'tn know which one you want.

Changing the function that contains line 21 to the following seems to
make it work (though I dunno if it's the best solution):

   // Overloads to make cleaner calling for client code
   void rtrimws(string& s) {
     rtrimws (s, static_cast<int(&)(int)> (isspace));
   }

[I added the cast to "int(&)(int)" to force it to choose a particular
variant of isspace...]


[*] One is the usual "int isspace(int)", but there's _also_ this:

  template<typename _CharT>
    bool
    isspace(_CharT, const locale&);


-Miles

-- 
Acquaintance, n. A person whom we know well enough to borrow from, but not
well enough to lend to.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

rtrimws: can't compile in g++ eric <cneric12lin0@gmail.com> - 2011-07-06 22:30 -0700
  Re: rtrimws: can't compile in g++ Miles Bader <miles@gnu.org> - 2011-07-07 15:11 +0900
    Re: rtrimws: can't compile in g++ eric <cneric12lin0@gmail.com> - 2011-07-06 23:26 -0700

csiph-web