I have found the answer from HowardHinnant in this thread. C++11 equivalent to boost shared_mutex
Unfortunately it seems to make use of the following macro which the Microsoft compiler (VS2015 x64) does not seem to support and the code needs to be C++11 and cross-platform.
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_END_NAMESPACE_STD
I have tried to change it to just
namespace std{
...
}
Then the compiler complains with the following message.
Severity Code Description Project File Line Column Source Suppression State Tool Error C2244 'std::unique_lock<_Mutex>::unique_lock': unable to match function definition to an existing declaration shared_mutex_test c:\documents\visual studio 2015\projects\shared_mutex_test\shared_mutex.hpp 1217 1 Build
Question, how to solve this. I need shared_mutex / shared_lock functionality and I have to be C++11 compliant. We have decided not to bring in a bigger library like Boost, hence if I could get HowardHinnant's implementation to work cross-platform it would be the optimal solution.
Many thanks.
Ps. I have not yet got a reputation high enough to comment on closed questions, hence I was forced to open up this new thread. Feel free to move it into the other thread.