From cppreference.com
Usage
: as the declaration of the statement
Example
Run this code
#include<iostream>#include<string>[[nodiscard]]constexprautoget_digits(conststd::string&string)noexcept{std::stringdigits{};for(constauto&character:string){if(character<'0'||character>'9')[[likely]]continue;// conditionally skips the following statementdigits+=character;}returndigits;}intmain()noexcept{std::cout<<get_digits("H3LL0, W0RLD!");}Output:
300 See also
statement:
,
statement:
,
(as case label declaration) etc:
statement:
statement:
statement:
loop and
:
,
loop and
: