c++ - String implicit conversion operators to const char*/wchar_t * -



c++ - String implicit conversion operators to const char*/wchar_t * -

i find mfc/atl cstring class convenient in win32 c++ code; in particular found convenient fact can pass instances of cstring win32 api's lpcwstr (i.e. const wchar_t *) parameters directly, implicit conversion operator defined cstring.

instead, when using std::wstring, explicit phone call .c_str() method required.

so, why stl string classes (both std::string , std::wstring) require explicit method phone call (c_str()) instead of defining implicit const char*/const wchar_t * conversion operator?

are there serious pitfalls hidden implicit conversion operators?

whatever theoretical concerns are, note in years of working cstring i've never been bitten feature. convenience far outweighs dangers.

c++ stl

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -