Suppose that you are writing a function that accepts an std::initializer_list
called list
, and that the function requires random access to li
According to Bjarne Stroustrup in Section 17.3.4.2 (p. 497) of The C++ Programming Language, 4th Edition:
Unfortunately, initializer_list doesn't provide subscripting.
No further reason is given.
My guess is that it's one of these reasons:
2 and 4 sound kind of weak. as does 3. My money's on 1.