Is this a proper use of a temporary std::string?
std::string getMyString() { return <make a string>; } ... HANDLE something = OpenSomething(getMyString().c_str(), ...); I've read Guaranteed lifetime of temporary in C++ and I believe that the temporary string will live until the assignment has been evaluated, i.e. plenty long enough to make this work as expected. Having once before run into an std::string lifetime-related bug (can't remember what it was) I'd rather double-check... Yes, this is fine. :-) The string will be destroyed at the end of the statement, at the semi colon. The destructor for the temporary will not be called until after