'Questions on iostream and initializer_list

I have received the following error for the following code on Visual Studio Code for Mac.

ArrayStudy.cpp:21:19: error: cannot deduce type of initializer list because std::initializer_list was not found; include <initializer_list>
    for (auto x : {10,21,32,43,54,65})

I included #include <initializer_list> after noting it was absent, but continued to receive the error. I'm using Apple clang version 13.0.0 (clang-1300.0.29.30).

At this point I am stumped. Can someone help me get this code running with a short explanation of what I missed?

#include <iostream>
#include <string>
#include <fstream>
#include <initializer_list>

void print();

int main(){

    print();

}

void print() {
    int v[] = {0,1,2,3,4,5,6,7,8,9};

    for (auto x : v)
        cout << x << '\n';

    for (auto x : {10,21,32,43,54,65})
        cout << x << '\n';
}
c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source