我试图将向量指针传递给基于范围的 for 循环作为其范围表达式。
以下是基于范围的 for 循环的语法:
attr(optional) for ( init-statement(optional) range-declaration : range-expression )
loop-statement
Run Code Online (Sandbox Code Playgroud)
参考自cppreference.com:
range-expression is evaluated to determine the sequence or range to iterate. Each element of the sequence, in turn, is dereferenced and is used to initialize the variable with the type and name given in range-declaration.
begin-expr and end-expr are defined as follows:
If range-expression is an expression of array type, then begin-expr is __range and end-expr is (__range + __bound), where __bound is the …Run Code Online (Sandbox Code Playgroud)