summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTea <tea.desouza@gmail.com>2015-11-17 17:05:56 +0800
committerTea <tea.desouza@gmail.com>2015-11-26 09:54:12 +0800
commitb72b0318e2802785c17be1fe8ed1b6899961df19 (patch)
treeefa7a1a24c420de673a7ebee343b3b1f68079907 /include
parent8e8d97d6206cac99eae3c16baaa2275a14e64ca7 (diff)
downloadcaffeonacl-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.hpp18
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_