Is there a proper formatter for boost::uint64_t to use with snprintf?
I am using boost/cstdint.hpp in a C++ project because I am compiling in
C++03 mode (-std=c++03) and I want to have fixed-width integers (they are
transmitted over the network and stored to files). I am also using
snprintf because it is a simple and fast way to format strings.
Is there a proper formatter to use boost::uint64_t with snprintf(...) or
should I switch to another solution (boost::format, std::ostringstream) ?
I am current using %lu but I am not fully happy with it as it may not work
on another architecture (where boost::uint64_t is not defined as long
unsigned), defeating the purpose of using fixed-width integers.
boost::uint64_t id
id = get_file_id(...)
const char* ENCODED_FILENAME_FORMAT = "encoded%lu.dat";
//...
char encoded_filename[34];
snprintf(encoded_filename, 34, ENCODED_FILENAME_FORMAT, id);
No comments:
Post a Comment