6
Sto cercando di accettare uno std :: initializer_list in un costruttore generica in questo modo:std :: ambiguità initializer_list in Visual Studio
template<typename T>
class Test{
std::vector<T> V;
Test(std::initializer_list<T>& list) : V(list){}
};
utilizzando
Test<int> test{ 1, 2, 3, 4 };
ma ho l'errore:
error C2440: 'initializing' : cannot convert from 'initializer-list' to 'Test<int>' No constructor could take the source type, or constructor overload resolution was ambiguous
Non sono sicuro di cosa sto facendo male qui.
VS sembra essere stato maturo, bello. Non sembra più permettere il legame '&' ai provvisori. –
Snarky, ma lo prenderò. Grazie. –