Is C ++ 17 std :: shared_mutex not yet available?

Looking at the C ++ compiler support , it seems that the version without restrictions std::shared_mutexis available in GCC 5.0+. However, even with gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04)compilation using -std=c++1zsimple initialization of the general mutex ends:

error: ‘shared_mutex’ in namespacestd’ does not name a type
        std::shared_mutex mutex_;

And no, I have included the correct headline #include <shared_mutex>.

It cannot find the correct title because it does not seem to exist. In fact, the linker uses the library in /usr/include/c++/5/shared_mutex, which contains only the implementation std::shared_timed_mutex(for example, the C ++ 14 standard).

I installed gcc-5 and g ++ - 5, adding the repository to ppa:ubuntu-toolchain-r/testand using update-alternativesto properly configure my cells.

Is there anything I can do to compile my code correctly using the latest C ++ 17 standard? And probably this is a stupid question, but is it too early to start using -std=c++1z, even if it should already be supported? Because it is supported, right?

+5
source share
3 answers

The confusion in cppreference was probably due to the fact that std::shared_mutexit was really added in GCC 5.0 in revision 200134 . But it was an early incarnation of this type based on a draft C ++ 1y. In fact, it was a synchronized mutex, which at that time was called std::shared_mutex.

++ 14 std::shared_mutex std::shared_timed_mutex, GCC 5.1 ( 5.x) libstdc++ . 207964.

, - GCC 5.x std::shared_mutex std::shared_mutex, ++ 17 GCC.

GCC 6.x ++ 1z untimed, std::shared_mutex. 224158.

, ++ 17 shared_mutex GCC 5.x. 5.x std::shared_mutex std::shared_mutex, 5.x std::shared_timed_mutex.

++ 17, , 2016 - 6.1, GCC std::shared_mutex ( , std::shared_mutex ++ 17 , , -std=gnu++17 -std=c++17 ).

GCC 5 2015 , ++ 17 . GCC 6.x 7.x ++ 1z (, , ).

+9

boost::shared_mutex std::shared_mutex

0

follow this link to install / upgrade to the latest version of GCC and G ++. http://tuxamito.com/wiki/index.php/Installing_newer_GCC_versions_in_Ubuntu

I tried this on my Ubuntu and succeeded.

0
source

All Articles