Add convenience _FORMAT macro
This commit is contained in:
parent
f1b2f37fe2
commit
da704ad820
@ -80,6 +80,16 @@ struct Timer {
|
|||||||
using Timings = std::map<std::string, Timer>;
|
using Timings = std::map<std::string, Timer>;
|
||||||
// Chrono:1 ends here
|
// Chrono:1 ends here
|
||||||
|
|
||||||
|
// A nice handy macro to do formatting
|
||||||
|
#define _FORMAT(_fmt, ...) \
|
||||||
|
([&] (void) -> std::string { \
|
||||||
|
int _sz = std::snprintf(nullptr, 0, _fmt, __VA_ARGS__); \
|
||||||
|
std::vector<char> _out(_sz + 1); \
|
||||||
|
std::snprintf(&_out[0], _out.size(), _fmt, __VA_ARGS__); \
|
||||||
|
return std::string(_out.data()); \
|
||||||
|
})()
|
||||||
|
|
||||||
|
|
||||||
// [[file:~/cuda/atrip/atrip.org::*Epilog][Epilog:1]]
|
// [[file:~/cuda/atrip/atrip.org::*Epilog][Epilog:1]]
|
||||||
}
|
}
|
||||||
// Epilog:1 ends here
|
// Epilog:1 ends here
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user