简体   繁体   中英

shared_mutex C++11 implementation

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.

Solved by just removing all code that failed. It seems it interfered with the available c++11 implementation of unique_lock. Since I can use C++11 I did not need that part of the code.

To fully solve it the complete unique_lock class probably needs to be implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM