Bugs item #3588371, was opened at 2012-11-18 13:40
Message generated for change (Comment added) made by lballabio You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3588371&group_id=12740 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Marcello Pietrobon (marcello-ptr) Assigned to: Nobody/Anonymous (nobody) Summary: (with fix) error C2679: no operator .. with stlp_std::string Initial Comment: vs2010 with STLPort.5.2.1 and Boost.1_52 XP SP3 error: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'stlpd_std::string' this happens with the files ql\currency.cpp (26) ql\errors.cpp : lines 53,56,58 ql\patterns\observable.hpp : line 140 The reason is that stlport doesn't give an implicit conversion from string to c_str() when needed (but I don't know what is the current standard on this specific point). The fixes is just to provide the c_str() member. We cannot use a str() member because it's not given with STLPort. So here the fixes for the different files: ql\currency.cpp : line 26 return out << c.code().c_str(); ql\errors.cpp : lines 53,56,58 std::ostringstream msg; #ifdef QL_ERROR_FUNCTIONS if (function != "(unknown)") msg << function.c_str() << ": "; #endif #ifdef QL_ERROR_LINES msg << "\n " << file.c_str() << "(" << line << "): \n"; #endif msg << message.c_str(); return msg.str(); ql\patterns\observable.hpp : line 140 QL_ENSURE(successful, "could not notify one or more observers: " << errMsg.c_str() ); Here is the full report for one file: 1>D:\Projs\Libraries\Public\QuantLib\QuantLib-Active\ql/patterns/observable.hpp(140): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'stlpd_std::string' (or there is no acceptable conversion) 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(297): could be 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<char,stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,char)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(304): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,char)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(311): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,signed char)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(318): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,unsigned char)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(325): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<char,stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,const char *)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(332): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,const char *)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(339): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,const signed char *)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(346): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::operator <<<stlpd_std::char_traits<char>>(stlpd_std::basic_ostream<_CharT,_Traits> &,const unsigned char *)' [found using argument-dependent lookup] 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(78): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(stlpd_std::basic_ostream<_CharT,_Traits> &(__cdecl *)(stlpd_std::basic_ostream<_CharT,_Traits> &))' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(79): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(stlpd_std::basic_ostream<_CharT,_Traits>::__ios_base_fn)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(80): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(stlpd_std::basic_ios<_CharT,_Traits> &(__cdecl *)(stlpd_std::basic_ios<_CharT,_Traits> &))' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(101): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(stlpd_std::basic_streambuf<_CharT,_Traits> *)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(104): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(unsigned char)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(106): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(short)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(107): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(unsigned short)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(108): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(int)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(115): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(size_t)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(117): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(long)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(118): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(unsigned long)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(120): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(__int64)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(121): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(unsigned __int64)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(123): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(float)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(124): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(double)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(126): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(long double)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(128): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(const void *)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> d:\Projs\Libraries\BSD\STLPort\STLport-Active\stlport\stl/_ostream.h(130): or 'stlpd_std::basic_ostream<_CharT,_Traits> &stlpd_std::basic_ostream<_CharT,_Traits>::operator <<(bool)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] 1> while trying to match the argument list '(stlpd_std::basic_ostream<_CharT,_Traits>, stlpd_std::string)' 1> with 1> [ 1> _CharT=char, 1> _Traits=stlpd_std::char_traits<char> 1> ] ---------------------------------------------------------------------- >Comment By: Luigi Ballabio (lballabio) Date: 2012-11-19 02:12 Message: Thanks for the report, but I'm a bit confused. A statement like "out << c.code()" isn't expected to trigger a conversion to C string; it just invokes operator << for std::string, which is defined by the standard. Do you have any idea why STLPort doesn't define it? ---------------------------------------------------------------------- Comment By: Marcello Pietrobon (marcello-ptr) Date: 2012-11-18 13:44 Message: I must add that probably this error comes with STLPort only The fix should be valid also without STLPort so I wouldn't surround the fixes with the condition: #ifdef _STLPORT_VERSION #endif By doing this the fixes would be like, of course: ql\currency.cpp : line 26 #ifdef _STLPORT_VERSION return out << c.code().c_str(); #else return out << c.code(); #endif ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3588371&group_id=12740 ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
You're right
#include <string>was forgotten I looked around http://stackoverflow.com/questions/8679473/error-c2679-binary-no-operator-found-which-takes-a-right-hand-operand-of The std::string operators are defined in the <string> header. The header <string.h> is for C-style string functions. On QuantLib 1.3 only three files need this fix: ql\patterns\observable.hpp ql\currency.cpp ql\errors.cpp and they all include ql\errors.hpp so my proposed fix is to add #include <string>in ql\errors.hpp and it works. Cheers, Marcello |
Free forum by Nabble | Edit this page |