Open Gomox11 opened 4 years ago
I am also experiencing a very similar issue, I have a class that I initialized using Boost.DI, that also has a std::mutex member.
Your workaround didn't work for me, so I worked around it by using a smart pointer for the std::mutex variable instead. Probably not ideal, but worked for me.
I am evaluating boost.DI and am running in the exact same issue, any details on why this is necessary ?
Funny thing being types that are non-copyable can be created by the injector to give to the created class.
Hello everyone!
Here is my example of creating an object of type
SomeClass
:This causes this compilation error because std::mutex is obviously not copyable:
error: use of deleted function ‘std::mutex::mutex(const std::mutex&)
If I wasn't using Boost.DI I could simply use
make_unique
without worrying about any copy or move operations:However, using Boost.DI, the only workaround I've found is defining the struct's move constructor:
How do you guys handle situations like this? Am I missing something? Thanks in advance :)