boost::filesystem::file_size() returns boost::uintmax_t. So, How to convert boost::uintmax_t to std::string?
boost::filesystem::file_size() returns boost::uintmax_t . So, How to convert boost::uintmax_t to std::string ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, you can use some simple approach like:
Or manually using the stringstream:
The operator for numbers is a member, so it should work on temporary even in C++03; some other overloads are free functions and in C++03 those don’t accept temporary, but you can use
std::stringstream().flush(), which returns lvalue reference and than alloperator<<overloads work.But it’s not just plain number. It’s file size. So it’s quite likely you should be rounding it and handling kB/MB/GB/KiB/MiB/GiB units. In which case have a look at libkibi.