diff --git a/include/atrip/Utils.hpp b/include/atrip/Utils.hpp index 4d1fb6b..42bf4f0 100644 --- a/include/atrip/Utils.hpp +++ b/include/atrip/Utils.hpp @@ -80,6 +80,16 @@ struct Timer { using Timings = std::map; // 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 _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]] } // Epilog:1 ends here