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) [[likely]] { if (character < '0' || character > '9') [[likely]] continue; // 按条件跳过以下语句 digits += character; } return digits; } int main() noexcept { std::cout << get_digits("H3LL0, W0RLD!"); }
输出:
300
参阅
|
(C++17 起) |
|
(C++23 起) |