Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7564
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Miles Bader <miles@gnu.org> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: rtrimws: can't compile in g++ |
| Date | Thu, 07 Jul 2011 15:11:18 +0900 |
| Organization | NEC Electronics |
| Lines | 35 |
| Message-ID | <buoipretybd.fsf@dhlpc061.dev.necel.com> (permalink) |
| References | <1495ae9f-43f4-47bc-967f-18a6bb54e7b4@t7g2000vbv.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net uo9nCCbQfH7Y9n8rH7h8tQMFqvViYB7d/F3cvpw7APi06eyuuh |
| Cancel-Lock | sha1:iZOQzYgo88zhqw6JMVQjDguxAYo= sha1:UgkMnFa+ojSo6BdfWsRyoZi0Z5M= |
| System-Type | x86_64-unknown-linux-gnu |
| Blat | Foop |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:7564 |
Show key headers only | 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
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