This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11163] New: Can't pass tolower as a parameter
- From: "cda at freshsources dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jun 2003 23:18:59 -0000
- Subject: [Bug c++/11163] New: Can't pass tolower as a parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11163
Summary: Can't pass tolower as a parameter
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: cda@freshsources.com
CC: gcc-bugs@gcc.gnu.org
Hello,
The following program is thought to be conforming by reputable members of the
C++ standards committee:
// Converts a string to lower case via transform()
#include <algorithm> // For transform
#include <cctype> // For tolower
#include <iostream>
#include <string>
using namespace std;
int main() {
string s("LOWER");
transform(s.begin(),s.end(),s.begin(), tolower);
cout << s << endl; // lower
} ///:~
g++ seems to require a cast, even though the cast is to the exact type of the
function already:
transform(s.begin(),s.end(),s.begin(),
static_cast<int(*)(int)>(tolower));
Do you why g++ 3.2 requires the cast? It seems to be having trouble deducing
the last argument to transform.
The error message from the first program is:
$ g++ toupper.cpp
toupper.cpp: In function `int main()':
toupper.cpp:9: no matching function for call to `transform(
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
I am running under Cygwin in Windows XP.
Thank you very much.