trainning_template

Dependencies:   mbed

Revision:
5:7534fc9248a8
diff -r fe1e9f9c7b33 -r 7534fc9248a8 converters.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/converters.h	Tue Dec 01 05:21:19 2020 +0000
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <cstdlib>
+#include <string>
+
+namespace std{
+static inline int stoi(const string &s) {
+    return atoi(s.c_str());
+}
+static inline long stol(const string &s) {
+    return atol(s.c_str());
+}
+static inline float stof(const string &s) {
+    return float(atof(s.c_str()));
+}
+#define _c_to_string(fmt,val) { \
+    char buf[16];\
+    snprintf(buf, sizeof(buf), fmt, val);\
+    return string(buf);\
+}
+static inline string to_string(bool v) {
+    _c_to_string("%d", (int)v);
+}
+static inline string to_string(char v) {
+    _c_to_string("%c", v);
+}
+static inline string to_string(int v) {
+    _c_to_string("%d", v);
+}
+static inline string to_string(long v) {
+    _c_to_string("%ld", v);
+}
+static inline string to_string(float v) {
+    _c_to_string("%f", v);
+}
+}
+
+inline bool  _p(bool x) { return x; }
+inline char  _p(char x) { return x; }
+inline int   _p(int x) { return x; }
+inline long  _p(long x) { return x; }
+inline float _p(float x) { return x; }
+inline void* _p(void* x) { return x; }
+inline const char* _p(const std::string &x) { return x.c_str(); }
+