| 111 | |
| 112 | template<typename T> |
| 113 | std::string NumToStringImplWrapper(T t, const char *fmt, int precision = 0) { |
| 114 | size_t string_width = NumToStringWidth(t, precision); |
| 115 | std::string s(string_width, 0x00); |
| 116 | // Allow snprintf to use std::string trailing null to detect buffer overflow |
| 117 | snprintf(const_cast<char *>(s.data()), (s.size() + 1), fmt, string_width, t); |
| 118 | return s; |
| 119 | } |
| 120 | #endif // FLATBUFFERS_PREFER_PRINTF |
| 121 | |
| 122 | // Convert an integer or floating point value to a string. |
no test coverage detected