[ ] Add fill-ins for std::begin() and std::end() for arrays and vectors.
[ ] Add C++ compliance regression tests in regression.html, ensure it works with raw arrays, vectors, and any user-defined classes that define begin() and end() functions.
Range-based for loops work by attempting behind-the-scenes calls to std::begin() and std::end(). These can't be literally reconstructed in C++ since they depend on templates and template specialization, which is not supported. However, separate overloads of these functions can be defined for arrays and vectors, and the range-based for loop construct can compile without necessarily needing to go through these functions at all (can just check whether it's an array, vector, or class and then proceed accordingly).
int arr[5] = {1, 2, 3, 4, 5};
for(int i : arr) {
cout << i << endl;
}
vector<int> vec = {1, 2, 3, 4, 5};
for(int &i : vec) {
i += 1;
}
Add support for C++ range-based for loops, e.g.
High level tasks:
grammar.txt
as needed to parse range-based for loop syntaxRangeForStatement
subclasses for throw and try/catch (base, typed, compiled, runtime versions for each)RangeForStatementOutlet
visualization "outlet"std::begin()
andstd::end()
for arrays and vectors.regression.html
, ensure it works with raw arrays, vectors, and any user-defined classes that definebegin()
andend()
functions.Range-based for loops work by attempting behind-the-scenes calls to
std::begin()
andstd::end()
. These can't be literally reconstructed in C++ since they depend on templates and template specialization, which is not supported. However, separate overloads of these functions can be defined for arrays and vectors, and the range-based for loop construct can compile without necessarily needing to go through these functions at all (can just check whether it's an array, vector, or class and then proceed accordingly).