| 269 | // Format at most ntrunc characters to the given stream. |
| 270 | template<typename T> |
| 271 | inline void formatTruncated(std::ostream& out, const T& value, int ntrunc) |
| 272 | { |
| 273 | std::ostringstream tmp; |
| 274 | tmp << value; |
| 275 | std::string result = tmp.str(); |
| 276 | out.write(result.c_str(), (std::min)(ntrunc, static_cast<int>(result.size()))); |
| 277 | } |
| 278 | #define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type) \ |
| 279 | inline void formatTruncated(std::ostream& out, type* value, int ntrunc) \ |
| 280 | { \ |