I'd like to pass a temporary std::list
to a function, but I do not know if it's possible to do so. I know it is possible to pass% temporary% with std::vector
:
#include <iostream>
#include <vector>
template<typename T>
void mostra(const std::vector<T>& myVec)
{
for(T var : myVec)
std::cout << var << "\n";
}
int main()
{
mostra<int>({12, 14, 28, 7, 10});
return 0;
}