I have this code which gets compiles using Sun Studio but gives error in g++
DBManager & DBManager::operator >> (UtlString &value)
{
//## begin DBManager::operator>>%921890065.body preserve=yes
if(_state == DBMRan){
_reader >> static_cast<std::string>(value);
}
return *this;
//## end DBManager::operator>>%921890065.body
}
DBManager.cpp:263: error: no match for âoperator>>â in â((DBManager*)this)->DBManager::_reader >> std::basic_string<char, std::char_traits<char>, std::allocator<char> >(((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&((jda::UtlString*)value)->jda::UtlString::<anonymous>))))â
DBReader.h:50: note: candidates are: virtual DBReader& DBReader::operator>>(char&)
DBReader.h:51: note: virtual DBReader& DBReader::operator>>(unsigned char&)
DBReader.h:52: note: virtual DBReader& DBReader::operator>>(short int&)
DBReader.h:53: note: virtual DBReader& DBReader::operator>>(short unsigned int&)
DBReader.h:54: note: virtual DBReader& DBReader::operator>>(int&)
DBReader.h:55: note: virtual DBReader& DBReader::operator>>(unsigned int&)
DBReader.h:56: note: virtual DBReader& DBReader::operator>>(long int&)
DBReader.h:57: note: virtual DBReader& DBReader::operator>>(long long int&)
DBReader.h:58: note: virtual DBReader& DBReader::operator>>(long unsigned int&)
DBReader.h:59: note: virtual DBReader& DBReader::operator>>(long long unsigned int&)
DBReader.h:60: note: virtual DBReader& DBReader::operator>>(float&)
DBReader.h:61: note: virtual DBReader& DBReader::operator>>(double&)
DBReader.h:62: note: virtual DBReader& DBReader::operator>>(DBDateTime&)
DBReader.h:63: note: virtual DBReader& DBReader::operator>>(DBBlob&)
DBReader.h:64: note: virtual DBReader& DBReader::operator>>(std::string&)
DBReader.h:65: note: virtual DBReader& DBReader::operator>>(DBNullIndicator&)
otlv4.h:35416: note: otl_connect& operator>>(otl_connect&, otl_stream&)
As you can see in above error message that DBReader class has operator>> which takes std::string by reference and UtlString class is derived from std::string so static_cast should not be a problem but still compiler complains that there is no matching method. Also can anyone tell me how to remove â charachter appearing in error message.
Thanks
You may build an temporary std::string from the UtlString.
std::string tmp(value);
if(_state == DBMRan){
_reader >> tmp;
}
That should at least work on both compilers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.