File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,16 @@ class vector : private std::vector<V, Allocator> {
160
160
*
161
161
* This function allows for easy enumeration, yielding a tuple of (index, element)
162
162
* pairs in each iteration. It is similar in functionality to Python's `enumerate()`.
163
+ * This function can be used in range-based with structured binding to iterate over
164
+ * indices and values at the same time.
165
+ *
166
+ * vtr::vector<IdType, ValueType> vec;
167
+ * for (const auto& [idx, value] : vec) {
168
+ * ...
169
+ * }
170
+ * It should be noted that value is returned by reference even if "&"
171
+ * does not appear after auto keyword. However, it is recommended to use "&"
172
+ * explicitly to avoid any confusion about value's scope.
163
173
*
164
174
* @ return An iterable wrapper that can be used in a range-based for loop to obtain
165
175
* (index, element) pairs.
You can’t perform that action at this time.
0 commit comments