I am unable to compile the below program.
void toSin(std::list<double>&& list)
{
std::for_each(list.begin(), list.end(), [](double& x)
{
x = sin(x);
});
}
int main()
{
std::list<double> list;
const double pi = 3.141592;
const double epsilon = 0.0000001;
for (double x = 0.0; x < 2 * pi + epsilon; x = x + pi / 16)
{
list.push_back(x);
}
// Start thread
std::thread th(toSin, std::move(list));
std::for_each(list.begin(), list.end(), [](double & x)
{
int count = static_cast<int>(10 * x + 10.5);
for (int i = 0; i < count; ++i)
{
std::cout.put('*');
}
std::cout << std::endl;
});
th.join();
return 0;
}
I get
error C2664: '
void (std::list<double,std::allocator<_Ty>> &&)
' : cannot convert argument 1 from 'std::list<double,std::allocator<_Ty>>
' to 'std::list<double,std::allocator<_Ty>> &&
'
Aucun commentaire:
Enregistrer un commentaire