void merge_sort_thread(vector<int>& array) {
if (1 < array.size()) {
vector<int> array1(array.begin(), array.begin() + array.size() / 2);
thread first= thread(merge_sort_thread,array1);
vector<int> array2(array.begin() + array.size() / 2, array.end());
thread second = thread(merge_sort_thread,array2);
first.join(); //wait for both ended
second.join();
merge (array1.begin(),array1.end(),array2.begin(),array2.end(),array.begin());
}
I am using Xcode to build and run, and it is a build failure. With prompt:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/thread:332:5: Attempt to use a deleted function
I know threading here is not efficient, but I want to know why this not work.