CPP
C++17¶
clamp¶
將給定值限制在指定的範圍內。
C++20¶
split¶
空白切割字串
for (auto token : s | views::split(' ')) {
//token 是 subrange iterator ,不是 string
if (token.begin() == token.end()) continue;//自動忽略多個空白 -> 否則會產生空字串
string_view sv(token.begin(), token.end());
}
- 切「任意空白」(space / tab / newline)