I want to generate a map of mutex elements, which probably need to be volatile. I am trying to define something of this sort:
typedef std::map<int key, volatile long mutex> tMutexMap;
tMutexMap myMutexMap;
and then use the simple map index, e.g.:
myMutexMap[10]=0;
myMutexMap[23]=1;
I'm using gcc 4.1.2. The gcc compiler doesn't like that code. I get an error
no matching function for call to 'std::pair....'"
What am I doing wrong?
C/C++'s volatile
is not like volatile
in some managed languages and has nothing to do with mutexes (see http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484). Depending on what you want to achieve consider using either std::mutex
(or boost::mutex
if you have a pre-C++11 standard library) or std::atomic<YourPreferredIntergalType>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With