Advertisement
Guest User

range based for

a guest
Aug 15th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. 6.5.4 The range-based for statement [stmt.ranged]
  2. 1 For a range-based for statement of the form
  3. for ( for-range-declaration : expression ) statement
  4. let range-init be equivalent to the expression surrounded by parentheses86
  5. ( expression )
  6. and for a range-based for statement of the form
  7. for ( for-range-declaration : braced-init-list ) statement
  8. let range-init be equivalent to the braced-init-list. In each case, a range-based for statement is equivalent
  9. to
  10. {
  11. auto && __range = range-init;
  12. for ( auto __begin = begin-expr,
  13. __end = end-expr;
  14. __begin != __end;
  15. ++__begin ) {
  16. for-range-declaration = *__begin;
  17. statement
  18. 86) this ensures that a top-level comma operator cannot be reinterpreted as a delimiter between init-declarators in the declaration
  19. of __range.
  20. ยง 6.5.4 128
  21.  
  22. c ISO/IEC N3337
  23. }
  24. }
  25. where __range, __begin, and __end are variables defined for exposition only, and _RangeT is the type
  26. of the expression, and begin-expr and end-expr are determined as follows:
  27. โ€” if _RangeT is an array type, begin-expr and end-expr are __range and __range + __bound, respectively,
  28. where __bound is the array bound. If _RangeT is an array of unknown size or an array of
  29. incomplete type, the program is ill-formed;
  30. โ€” if _RangeT is a class type, the unqualified-ids begin and end are looked up in the scope of class _RangeT
  31. as if by class member access lookup (3.4.5), and if either (or both) finds at least one declaration, beginexpr
  32. and end-expr are __range.begin() and __range.end(), respectively;
  33. โ€” otherwise, begin-expr and end-expr are begin(__range) and end(__range), respectively, where begin
  34. and end are looked up with argument-dependent lookup (3.4.2). For the purposes of this name lookup,
  35. namespace std is an associated namespace.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement