jeudi 10 août 2017

How to pass std::ofstream& into functional params?

This is my code

void timer_start(std::function<void(std::ifstream*,std::ofstream&, char*[])> func, unsigned int interval, std::ifstream* ifs, std::ofstream& ofs, char* argv[])
{
    std::thread([func, interval, ifs, ofs, argv]()
    {
        while (true)
        {
            auto x = std::chrono::steady_clock::now() + std::chrono::milliseconds(interval);
            func(ifs, (std::ofstream&)ofs, argv);
            std::this_thread::sleep_until(x);
        }
    }).join();
}

the following error is shown in the second line of the above code while passing ofs

Error C2280 'std::basic_ofstream>::basic_ofstream(const std::basic_ofstream> &)': attempting to reference a deleted function

Why this happens and kindly help me out..

Aucun commentaire:

Enregistrer un commentaire