
23 Feb
2004
23 Feb
'04
5:15 p.m.
Would it be possible to add function c_str() into format interface? It would return const char/wchar_t* to internal string buffer. Use cases for such function: 1. void foo(const char*) { ...} format f("...") f % ... foo(f.c_str()); This is shorter and faster than foo(f.str().c_str()); No temporary gets created. 2. // class used to accept any string type struct parm_string { parm_string(const char* s) : str_(s) {} parm_string(const std::string& s) : str_(s.c_str()) {} const char* str_; }; void foo(parm_string) { ... } format f("...") f % ... // ERROR - pointer to deleted temporary gets used inside foo() foo(f.str()); foo(f.c_str()); // would be OK /Pavel