---
name: "std::shared_lock"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::shared_lock/3cxx"
---

# std::shared\_lock(3cxx)

shared\_lock

## NAME

std::shared\_lock\< \_Mutex \> - shared\_lock

## SYNOPSIS

`#include <shared_mutex>`

### Public Types

**typedef** **\_Mutex** **mutex\_type**\

### Public Member Functions

**shared\_lock** (**mutex\_type** &**\_\_m**)\
 **shared\_lock** (**mutex\_type** &**\_\_m**, **adopt\_lock\_t**)\
 template\<**typename** \_Rep , **typename** **\_Period** \> **shared\_lock** (**mutex\_type** &**\_\_m**, const **chrono::duration**\< \_Rep, **\_Period** \> &**\_\_rel\_time**)\
 template\<**typename** **\_Clock** , **typename** **\_Duration** \> **shared\_lock** (**mutex\_type** &**\_\_m**, const **chrono::time\_point**\< **\_Clock**, **\_Duration** \> &**\_\_abs\_time**)\
 **shared\_lock** (**mutex\_type** &**\_\_m**, **defer\_lock\_t**) noexcept\
 **shared\_lock** (**mutex\_type** &**\_\_m**, **try\_to\_lock\_t**)\
 **shared\_lock** (**shared\_lock** &&**\_\_sl**) noexcept\
 **shared\_lock** (**shared\_lock** const &)=**delete**\
 **void** **lock** ()\
 **mutex\_type** \* **mutex** () const noexcept\
 **operator bool** () const noexcept\
 **shared\_lock** & **operator=** (**shared\_lock** &&**\_\_sl**) noexcept\
 **shared\_lock** & **operator=** (**shared\_lock** const &)=**delete**\
 bool **owns\_lock** () const noexcept\
 **mutex\_type** \* **release** () noexcept\
 **void** **swap** (**shared\_lock** &**\_\_u**) noexcept\
 bool **try\_lock** ()\
 template\<**typename** \_Rep , **typename** **\_Period** \> bool **try\_lock\_for** (const **chrono::duration**\< \_Rep, **\_Period** \> &**\_\_rel\_time**)\
 template\<**typename** **\_Clock** , **typename** **\_Duration** \> bool **try\_lock\_until** (const **chrono::time\_point**\< **\_Clock**, **\_Duration** \> &**\_\_abs\_time**)\
 **void** **unlock** ()\

## Detailed Description

### template\<typename \_Mutex\>

class std::shared\_lock\< \_Mutex \>"shared\_lock

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
