My code goes like this :-
#include <iostream>
#include <thread>
using namespace std;
void swapno (int &a, int &b)
{
int temp=a;
a=b;
b=temp;
}
int main()
{
int x=5, y=7;
cout << "x = " << x << "\ty = " << y << "\n";
thread t (swapno, x, y);
t.join();
cout << "x = " << x << "\ty = " << y << "\n";
return 0;
}
This code fails to compile. Can anyone help me out why ?
Not only this code but the code in this also failed to send std::unique_ptr
by reference. What's wrong with std::thread
?