[Bug c++/103583] Range loop: "error: 'begin' was not declared in this scope" when 'end' is missing
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 6 14:30:35 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103583
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The error is technically correct.
If your class had both begin and end, then the range-based for loop would use
a.begin() and a.end(). But because it doesn't have both, the loop uses begin(a)
and end(a), neither of which is defined. And that's what the error says.
More information about the Gcc-bugs
mailing list