I am currently in the process of updating my language knowledge (to C++17). I was trying to get this code to compile using gcc and couldn't figure it out so I tried MSVC and clang and both seem okay with this code -- is there anything wrong with this bit of code?
gcc seems to be complaining about instantiating a tuple<> with no template parameters which is odd:
prog.cc: In instantiation of 'C::C(U&& ...) [with U = {const A&, const B&}; T = {}]': prog.cc:32:14: required from here prog.cc:12:49: error: no matching function for call to 'std::tuple<>::tuple(const A&, const B&)' 12 | : container( std::forward(params)... ) | ^
#include <tuple>
struct A {};
struct B {};
template<typename... T>
struct C
{
template<typename... U>
C(U&&... params)
: container( std::forward<U>(params)... )
{}
std::tuple<T...> container;
};
template <class... T>
C(T&&...)->C<std::decay_t<T>...>;
int main(void)
{
const A a;
const B b;
C c2(a, b); // <-- this fails on gcc, okay on msvc and clang
}