when I was reading a well known book its been said.
std::mutex is a move-only type (i.e., a type that can be moved, but not copied), a side effect of adding m to Polynomial is that Polynomial loses the ability to be copied
Here the author Scott add a Std::mutex M
as a member variable to a class polynomial in the context of explaining why one should protect access to const member variable of a class(while multi-threading). I understood the concept he explained. but one thing which I need to have some more explanation is "why Adding a move only type to a class makes that class as move only type not copy-able"?, why types like std::mutex
and std::atomic
is move only type by default? how can we get over with it if we want to perform copy operation even when adding move only type of variable to our class?
Aucun commentaire:
Enregistrer un commentaire