I need to be able to store "n" number of mutexes at any given time.
These URLs relate directly to my problem storing mutexes in a vector/deque c++ How can I use something like std::vector<std::mutex>?
And I am confident I understand why mutexes can not be stored in containers that might have to move them (as mutexes can't be moved). My question is, have there been any developments in c/c++ since these articles were posted that I might be able to utilize that I don't know about?
A simple array would be nice, but won't work for obvious reasons. A vector or similar would work, except for the fact that the mutexes can't be moved and therefore generates a compiler error. The following does work, but seems to be decried by some. Is there a programmatic reason why the following code example shouldn't be used to solve the problem?
std::vector<std::timed_mutex*> myMutexes;
myMutexes.push_back(new std::timed_mutex());