The following snippet compiles in gcc 12.1 but not in gcc 11.1. Unfortunately, I only have gcc 11 at hand as I'm crosscompiling for a microcontroller. Is there a way to make it work? Also what is this cryptic "use 'auto' for an abbreviated function template" all about?
#include <cstdio>
#include <tuple>
template <typename T>
struct channel
{
int a;
T b;
};
template <typename... Channels>
struct light
{
light(const std::tuple<Channels...>& channels)
: channels_ { channels }
{
}
std::tuple<Channels...> channels_;
};
int main()
{
light li(std::tuple{channel(2, 2), channel(2,false)});
}
Error (only in gcc 11.1):
<source>:25:14: error: class template placeholder 'std::tuple' not permitted in this context
25 | light li(std::tuple{channel(2, 2), channel(2,false)});
| ^~~
<source>:25:14: note: use 'auto' for an abbreviated function template
Interestingly, gcc 10.4 has something even different to say:
<source>:25:14: error: 'auto' parameter not permitted in this context
25 | light li(std::tuple{channel(2, 2), channel(2,false)});
| ^~~
I need a workaround that allows me to not specify all the template parameters of std::tuple as that would blow up my initializer to the point of unrecognizeability :/