modern-cpp-tutorial icon indicating copy to clipboard operation
modern-cpp-tutorial copied to clipboard

proposal: discuss internals regarding for loop

Open ZenYuan opened this issue 5 years ago • 1 comments

Motivation

Please briefly describe your motivation.

Requirements

Please list all of your suggestions.


动机

区间for循环可以加上内部机制;读者可以更加灵活运用区间for循环

需求说明

比如for循环作用于自己定义的容器模板;该容器需要包含begin和end模板成员函数; for(auto x : range_expression)内部机制: { init-statement auto && __range = range_expression ; auto __begin = begin_expr ; auto __end = end_expr ; for ( ; __begin != __end; ++__begin) { range_declaration = *__begin; loop_statement } } 引用:https://en.cppreference.com/w/cpp/language/range-for

ZenYuan avatar Dec 22 '20 03:12 ZenYuan

PR welcome

changkun avatar Dec 22 '20 08:12 changkun