This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/5133: Problems with toupper
- From: paolo at gcc dot gnu dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, schmid at snake dot iap dot physik dot tu-darmstadt dot de
- Date: 16 Dec 2001 21:53:55 -0000
- Subject: Re: libstdc++/5133: Problems with toupper
- Reply-to: paolo at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, schmid at snake dot iap dot physik dot tu-darmstadt dot de, gcc-gnats at gcc dot gnu dot org
Synopsis: Problems with toupper
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sun Dec 16 13:53:55 2001
Responsible-Changed-Why:
Taking care of this.
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Sun Dec 16 13:53:55 2001
State-Changed-Why:
Hi Peter,
in Josuttis, pp. 499 and 718 I find an explanation of what
is happening with your testcase. In a nutshell, tolower and
toupper are old C functions (you may use them through
cctype) whereas std::toupper(c, loc) (and the corresponding
tolower) are global functions of the C++ locales.
Therefore, your testcase should be changed to:
#include <string>
#include <iostream>
#include <algorithm>
#include <cctype>
int main()
{
std::string s("Hallo");
//std::transform (s.begin(), s.end(), s.begin(), std::tolower);
//std::transform (s.begin(), s.end(), s.begin(), ::tolower);
std::transform (s.begin(), s.end(), s.begin(), tolower);
std::cout << "lowered: " << s << std::endl;
}
which indeed compiles and runs fine.
Ok?
Cheers,
Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5133