mardi 16 août 2016

Range-Based Loop Error

I have defined an enum Channel elsewhere. The first loop compiles and behaves. The second creates a compiler error. I'm using GCC ARM Embedded 4.9 with -std=c++14.

error: deducing from brace-enclosed initializer list requires #include<initializer_list>

I tried to include this but it could not be found by my compiler.

static constexpr Channel TABLE[] = {CHANNEL_1, CHANNEL_8, CHANNEL_9, CHANNEL_14, CHANNEL_15};

for (auto channel : TABLE)
{
    printf("%d", channel);
}

for (auto channel : {CHANNEL_1, CHANNEL_8, CHANNEL_9, CHANNEL_14, CHANNEL_15})
{
    printf("%d", channel);
}

Aucun commentaire:

Enregistrer un commentaire