| 179 | |
| 180 | template <typename Out> |
| 181 | void writeWithWidthStrict(Out & out, std::string_view s, size_t width) |
| 182 | { |
| 183 | constexpr std::string_view ellipsis = "…"; |
| 184 | if (s.size() > width) |
| 185 | if (width <= ellipsis.size()) |
| 186 | out << s.substr(0, width); |
| 187 | else |
| 188 | out << s.substr(0, width - ellipsis.size()) << ellipsis; |
| 189 | else |
| 190 | out << s; |
| 191 | } |
| 192 | |
| 193 | } |
| 194 |