C++ 关键字: continue
来自 cppreference.com
[编辑] 用法
-
continue
语句: 作为语句的声明
[编辑] 示例
运行此代码
#include <iostream> #include <string> [[nodiscard]] constexpr auto get_digits(const std::string& string) noexcept { std::string digits{}; for (const auto& character: string) { if (character < '0' || character > '9') [[likely]] continue; // conditionally skips the following statement digits += character; } return digits; } int main() noexcept { std::cout << get_digits("H3LL0, W0RLD!"); }
输出
300
[编辑] 另请参阅
|
(自 C++17 起) |
|
(自 C++23 起) |
(自 C++20 起) |