How to determine the (printed) length of std :: string with tab expansion?

Given a C ++ variable std::stringthat includes tabs, is it possible to determine the length of this line, how will it appear on the "screen"? i.e:.

std::string var = "\t\t\t";
std::cout << var.length();          // result: 3
std::cout << printed_length(var);   // result: 3*(# of spaces per tab)
+5
source share
2 answers

. "" (, , ), . , -, (, ). " " , .

"", 8- . , , . ( ) .

: - , , , .

+3

, .

.

expansion_count = n_spaces - (current_count % n_spaces);
+3

All Articles