Monday, July 10, 2017

C++11: range-for: initializer list

An initializer list can be used with a range. Here is an example:
#include
#include
using namespace std;
int main()
 {
    for (auto i : {10, 11, 12}) cout << i << " ";
    return 0;
}
// Output: 10 11 12

No comments:

Post a Comment