名稱空間
變體
操作

C++ 關鍵字: continue

來自 cppreference.com
< cpp‎ | 關鍵字
 
 
C++ 語言
 
 

[編輯] 用法

[編輯] 示例

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