diff options
author | Tea <tea.desouza@gmail.com> | 2015-11-17 17:05:56 +0800 |
---|---|---|
committer | Tea <tea.desouza@gmail.com> | 2015-11-26 09:54:12 +0800 |
commit | b72b0318e2802785c17be1fe8ed1b6899961df19 (patch) | |
tree | efa7a1a24c420de673a7ebee343b3b1f68079907 /include | |
parent | 8e8d97d6206cac99eae3c16baaa2275a14e64ca7 (diff) | |
download | caffeonacl-b72b0318e2802785c17be1fe8ed1b6899961df19.tar.gz caffeonacl-b72b0318e2802785c17be1fe8ed1b6899961df19.tar.bz2 caffeonacl-b72b0318e2802785c17be1fe8ed1b6899961df19.zip |
replace snprintf with a C++98 equivalent
Diffstat (limited to 'include')
-rw-r--r-- | include/caffe/util/format.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/caffe/util/format.hpp b/include/caffe/util/format.hpp new file mode 100644 index 00000000..925ad2e0 --- /dev/null +++ b/include/caffe/util/format.hpp @@ -0,0 +1,18 @@ +#ifndef CAFFE_UTIL_FORMAT_H_ +#define CAFFE_UTIL_FORMAT_H_ + +#include <iomanip> // NOLINT(readability/streams) +#include <sstream> // NOLINT(readability/streams) +#include <string> + +namespace caffe { + +inline std::string format_int(int n, int numberOfLeadingZeros = 0 ) { + std::ostringstream s; + s << std::setw(numberOfLeadingZeros) << std::setfill('0') << n; + return s.str(); +} + +} + +#endif // CAFFE_UTIL_FORMAT_H_ |