I’m trying to use the standard shared_mutex as a structure parameter but the execution keeps saying:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted
Here is the piece of code:
template <typename Object>
struct Foo
{
...
void bar()
{
// This commented code works
// std::shared_mutex mutex;
// const std::unique_lock<std::shared_mutex> lock(mutex);
const std::unique_lock<std::shared_mutex> lock2(this->mutex);
}
private:
mutable std::shared_mutex mutex;
}
// this is used somewhere else within a shared_ptr:
std::share_ptr<Foo<MyObject>> foo;
foo->bar();
(I’m compiling in std c++20 with g++13)
As mentioned, the commented code works well so I exclude some environment supports issues. In addition, if I try to use a simple mutex (with no mutable) it just result to a segmentation fault. Someone can help me with that?