On Mar 15, 5:12 pm, Thomas Maeder <[EMAIL PROTECTED]> wrote:
>
> Unfortunately, the situation is more complicated:
> - <cctype> declares the 1 argument version of std::tolower()
> - <locale> declares the 2 argument version of std::tolower()
> - in C++, <ctype.h> works like <cctype> but adds a using declaration
>   for std::tolower in the global namespace
>
> And in reality, C++ implemetations often don't implement the 3rd item
> correctly. So the best thing IMHO is to not #include <ctype.h> in new
> code and rely on the tolower() overloads in namespace std.
>
> > 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.
>
> There is no such thing as <cctype.h> in C++. It's either <cctype> or
> <ctype.h>. Both declare a 1 argument version of std::tolower().
>

You've actually brought up a couple of other points I have questions
about. Firstly about the difference between <ctype.h> and <cctype>

The post at http://www.thescripts.com/forum/thread60652.html states
that:

"The problem is that most implementations of the standard C <ctype.h>
header define functions like toupper/tolower/etc as macros. To make it
work in STL algorithms, you have to include <cctype> header instead of
<ctype.h>. At least on my PC (Debian/gcc 3.3), <cctype> undefines all
tolower/etc macros and pulls ::tolower/::toupper/etc functions into
std namespace, so that your sample will work fine."

Is this accurate (in that it won't work because the functions are
macros)?

By the way, the function call was:

string foo = "Some Mixed Case Text";
transform(foo.begin(), foo.end(), foo.begin(), tolower);

Taras
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to