C++ 关键词:continue

来自cppreference.com
< cpp‎ | keyword


 
 
C++ 语言
 
 

用法

示例

#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 起)