| 277 | // Format at most ntrunc characters to the given stream. |
| 278 | template<typename T> |
| 279 | inline void formatTruncated(std::ostream& out, const T& value, int ntrunc) |
| 280 | { |
| 281 | std::ostringstream tmp; |
| 282 | tmp << value; |
| 283 | std::string result = tmp.str(); |
| 284 | out.write(result.c_str(), (std::min)(ntrunc, static_cast<int>(result.size()))); |
| 285 | } |
| 286 | #define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type) \ |
| 287 | inline void formatTruncated(std::ostream& out, type* value, int ntrunc) \ |
| 288 | { \ |