I'm running into an error with a more complicated class structure which I have boiled down to the below simple test case. The actual intent is to use a ctor with parameters, but the error occurs even when explicitly calling the empty ctor.
class TestFun{
public:
explicit TestFun(const std::function<void()>& fun) : m_thread(fun) {}
~TestFun() {m_thread.join();}
private:
std::thread m_thread;
};
class Test : public TestFun{
public:
Test() : TestFun( [this](){std::cout << "test\n";}) {}
};
std::vector<Test> tests(10); // This compiles
std::vector<Test> tests(10, Test()); // This gives an error
The error is:
/usr/include/c++/11/bits/stl_uninitialized.h:288:63: error: static assertion failed: result type must be constructible from input type
What's going on here?