Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-02-23 12:15:35

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:

void foo(const char*) { ...}

format f("...")
f % ...

This is shorter and faster than

No temporary gets created.


// 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.c_str()); // would be OK


Boost list run by bdawes at, gregod at, cpdaniel at, john at