# std::latch

C++
 语言 标准库头文件 自立与有宿主实现 具名要求 语言支持库 概念库 (C++20) 诊断库 工具库 字符串库 容器库 迭代器库 范围库 (C++20) 算法库 数值库 本地化库 输入/输出库 文件系统库 (C++17) 正则表达式库 (C++11) 原子操作库 (C++11) 线程支持库 (C++11) 技术规范

(C++11)
(C++20)
(C++20)
`this_thread` 命名空间
 get_id(C++11) yield(C++11)
 sleep_for(C++11) sleep_until(C++11)

 mutex(C++11) recursive_mutex(C++11) shared_mutex(C++17)
 timed_mutex(C++11) recursive_timed_mutex(C++11) shared_timed_mutex(C++14)

(C++11)

latch
(C++20)
(C++20)
future
 launch(C++11) future_status(C++11) future_error(C++11) future_category(C++11) future_errc(C++11)

std::latch

 定义于头文件 `` class latch; (C++20 起)

`latch``ptrdiff_t` 类型的向下计数器，它能用于同步线程。在创建时初始化计数器的值。

### 成员函数

(公开成员函数)

(公开成员函数)
operator=
[被删除]
`latch` 不可赋值
(公开成员函数)

(公开成员函数)

(公开成员函数)

(公开成员函数)

(公开成员函数)
[静态]

(公开静态成员函数)

### 参阅

 barrier(C++20) 可复用的线程屏障 (类模板)
{"ft_lang_label":"__label__zh","ft_lang_prob":0.9228204,"math_prob":0.99506843,"size":504,"snap":"2023-14-2023-23","text_gpt3_token_len":401,"char_repetition_ratio":0.202,"word_repetition_ratio":0.0,"special_character_ratio":0.28769842,"punctuation_ratio":0.0945946,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9790581,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-05T06:13:33Z\",\"WARC-Record-ID\":\"<urn:uuid:0b2aca47-81bb-4aa0-8a55-ea963f8382b3>\",\"Content-Length\":\"28548\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a753456c-f9b5-48b3-9fe8-fdd0b2ae712d>\",\"WARC-Concurrent-To\":\"<urn:uuid:fdd07c2e-ff7a-4ac6-9e6b-59257623b5de>\",\"WARC-IP-Address\":\"172.67.137.152\",\"WARC-Target-URI\":\"https://www.apiref.com/cpp-zh/cpp/thread/latch.html\",\"WARC-Payload-Digest\":\"sha1:4G5GH7JPROJCHGODWIGE6T7GLR6ERGBX\",\"WARC-Block-Digest\":\"sha1:7WLLBVPTN7XGHEYKSD5NHN6MJUUVBZHJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224651325.38_warc_CC-MAIN-20230605053432-20230605083432-00403.warc.gz\"}"}