|
-
July 20th, 2010, 04:05 PM
#3
Re: [g++] Getting an error while using reinterpret_cast operator
 Originally Posted by laserlight
There is no need for a cast in the first place, since a pointer to the non-template version of tolower as borrowed from the C standard library is already of type int (*)(int).
Yes, it is, but there is a problem when we use this name in transform function in g++:
Code:
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string a;
transform(a.begin(), a.end(),
a.begin(), tolower);
}
We're getting the following error:
error: 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> > >,
<unresolved overloaded function type>)'
 Originally Posted by laserlight
But if it was not... I do not think that such function pointer conversions are well defined.
Why do you think so ? Comeau C++ Online doesn't show any errors in the example with reinterpret_cast operator...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|