help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tolower - std namespace?


From: sanjeev . sapkota
Subject: tolower - std namespace?
Date: Fri, 14 Mar 2008 20:11:08 -0700 (PDT)
User-agent: G2/1.0

Hi everyone,

I've read multiple posts about how to get the 'tolower' function to
work in gcc. From what I understand, the problem is that there are two
versions - you must cast to specify which version you want to use.

  transform(tempString.begin(),tempString.end(),tempString.begin(),
            (int(*)(int))std::tolower);

This works with gcc, but not with MS Visual Studio 2003. It only works
with MS Visual Studio 2003 if you remove the std::.

I'm not quite sure why this is, but I read that there are two versions
of tolower. One is the global namespace, and comes from ctype.h, and
the other one is in the std namespace. This link (http://
www.thescripts.com/forum/thread161158.html) states that std::tolower
takes two arguments, not one. This link (http://www.cplusplus.com/
reference/clibrary/cctype/tolower.html) shows that the tolower in
cctype.h takes a single argument. I am also aware that transform must
take a binary argument.

So, if the problem *is* because the std::tolower version takes 2
arguments (and not one), this lead me to ask why it works in gcc? The
only reason I can think of is maybe perhaps the gcc implementation of
std::tolower provides some parameter defaults, which the MS version
does not? This 'option of providing defaults'  is explained at:
http://www.gotw.ca/gotw/064.htm:

"The standard library specification deliberately gives some leeway to
implementers when it comes to member functions. Specifically:

- A member function signature with default parameters may be replaced
by "two or more member function signatures with the equivalent
behavior."

- A member function signature may have additional defaulted
parameters.
"

Any comments as per my guesses - are they correct?

Taras

PS: I'm finding that writing portable code when using a STANDARD
library is much harder than I would think it is *sigh*


reply via email to

[Prev in Thread] Current Thread [Next in Thread]