I am coding a multithread program.
I have a multimap that will receive data from many threads.
Therefore I want to wrap the class in a derived class with overwitten members as necessary.
This is my code to do his:
1 2 3 4 5 6 7 8 9 10 11 12
template <typename T> class Border_map :
public std::multimap<T, RC>
std::mutex _mutex ;
std::multimap<T, RC>::iterator insert ( const value_type& x ) // ERROR HERE
std::lock_guard<std::mutex> guard (_mutex) ;
return std::multimap<T, RC>::insert(x) ;
The compiler does not understand any of my attempts at describing the return type of the function insert. What should I write instead?
Thanks. it works. I was not familiar with this use of keyword typename. As far as I understood what I read since your reply, we must use it anywhere the compiler cannot understand from te context that we are actually describing a type name. Correct?
why did you advise not to inherit from std::multimap?
I chose heritage because I did not want to overwrite all the methods I will be using, but only those for which I need a lock. Is there anything wrong in this logic? or is there something more important that I have ignored?
I thought it was in the scope, but the compiler did not accept a line like this:iterator insert(...)