Is C++17 std::shared_mutex not available yet?
The confusion on cppreference was probably because std::shared_mutex
really was added to GCC 5.0, in revision 200134. But that was the early incarnation of that type based on a C++1y draft. In fact it was the timed shared mutex, which was called std::shared_mutex
at the time.
Before the final C++14 standard was published std::shared_mutex
was renamed to std::shared_timed_mutex
, and so before the GCC 5.1 release (which is the first release in the 5.x series) the type in libstdc++ was renamed, see revision 207964.
So although at one point during the GCC 5.x pre-release phase there was a std::shared_mutex
type, it wasn't the C++17 untimed one, and it got renamed before appearing in any official release of GCC.
Then, during the development of the GCC 6.x release series the C++1z untimed shared mutex got added, reusing the std::shared_mutex
name. That's the commit T.C. linked to in the comments above, revision 224158.
So the C++17 untimed shared_mutex
was never in any GCC 5.x version. For a brief period before the first 5.x release there was a timed one called std::shared_mutex
, but in all proper 5.x releases it's called std::shared_timed_mutex
.
The first release to ship the C++17 untimed one was 6.1 in April 2016, so with any GCC release after that you can use std::shared_mutex
(as long as you enable C++17 in the compiler, e.g. with the -std=gnu++17
or -std=c++17
flag).
GCC 5 was released in 2015, so expecting to be able to use C++17 with that version is a bit unrealistic. GCC 6.x and 7.x have pretty good C++1z support (but only based on the current drafts at the time of release, of course).