std::thread
ile ilgili bir sorunla karşılaşıyorum çünkü otomatik olarak belirtilen argümanları alan işlevleri kabul etmiyor. İşte bazı örnek kod:Neden std :: thread ile otomatik kullanamıyorum?
#include <iostream>
#include <vector>
#include <thread>
using namespace std;
void seev(const auto &v) // works fine with const vector<int> &v
{
for (auto x : v)
cout << x << ' ';
cout << "\n\n";
}
int main()
{
vector<int> v1 { 1, 2, 3, 4, 5 };
thread t(seev, v1);
t.join();
return 0;
}
Fakat derleyici diyor:
[Error] no matching function for call to 'std::thread::thread(<unresolved overloaded function type>, std::vector<int>&)'
neden oluyor? Dil veya GCC (4.9.2) ile ilgili bir sorun mu var? ++
template <class T>
void seev (const T &v) ...
C olamaz türlerin açık spec olmadan vücut bulmuş şablonu:
Bu 'C++ 14' mü? – Alex
evet, @Alex –
@AnkitAcharya Hayır, öyle değil. Bu bir gcc uzantısı ve C++ 17 için önerildi. – inf