The following program fails to compile with g++ -std=c++11 -Wall -Werror test.cpp -o test.o:
#include <thread>
using namespace std;
void fill(int n) {
return;
}
int main() {
thread test(fill, 5);
}
test.cpp:9:12: error: no matching constructor for initialization of 'std::__1::thread'
thread test(fill, 5);
^ ~~~~~~~
Is it because fill is conflicting with std::fill from #include <algorithm>? I haven't included this but I suppose <thread> might've.
Changing my function name to fillie (or anything else pretty much) allows it to compile correctly without linking pthread.
I ask because it is a strange compiler error message, and also it means that the thread constructor can't disambiguate which function I am using based on the parameters (which sort of makes sense, but wanted confirmation).
Aucun commentaire:
Enregistrer un commentaire