I have a class that writes to a file on a thread
class A{ public: void writeToFile(ofstream& outFile, obj &a) { //... } thread memberThread1(ofstream& outFile, obj &a) { cout << "Thread 1 is now running " << endl; return thread ([=]{ writeToFile(outFile, a);}); } }; I got a few errors on the lambda function.
cannot convert argument 1 from 'const std::ofstream' to 'std::ofstream &'
note: Conversion loses qualifiers
I was able to fix the second argument a by doing a const_cast but I could not figure out how to fix the first argument.
Thanks!