llvm / llvm/llvm-project

[libc++] P0355R7: Reject misused `Clock` type for which `is_clock_v<Clock>` is `false` for multi-threading components

Open
#167,071 1 comment 0 reactions 0 assignees View on GitHub
c++20 chrono libc++ threading
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

**Link:** https://wg21.link/p0355r7, https://eel.is/c++draft/thread.req.paramname

Affected components:
- [ ] `this_thread::sleep_until` [[thread.thread.this]](https://eel.is/c++draft/thread.thread.this)
- [ ] `timed_mutex::try_lock_until` [[thread.timedmutex.recursive]](https://eel.is/c++draft/thread.timedmutex.recursive)
- [ ] `recursive_timed_mutex::try_lock_until` [[thread.timedmutex.recursive]](https://eel.is/c++draft/thread.timedmutex.recursive)
- [ ] `shared_timed_mutex::try_lock_until` [[thread.sharedtimedmutex.class]](https://eel.is/c++draft/thread.sharedtimedmutex.class)
- [ ] `shared_timed_mutex::try_lock_shared_until` [[thread.sharedtimedmutex.class]](https://eel.is/c++draft/thread.sharedtimedmutex.class)
- [ ] `unique_lock`'s constructor from `time_point` [[thread.lock.unique.cons]](https://eel.is/c++draft/thread.lock.unique.cons)
- [ ] `unique_lock::try_lock_until` [[thread.lock.unique.locking]](https://eel.is/c++draft/thread.lock.unique.locking)
- [ ] `shared_lock`'s constructor from `time_point` [[thread.lock.shared.cons]](https://eel.is/c++draft/thread.lock.shared.cons)
- [ ] `shared_lock::try_lock_until` [[thread.lock.shared.locking]](https://eel.is/c++draft/thread.lock.shared.locking)
- [ ] `condition_variable::wait_until` [[thread.condition.condvar]](https://eel.is/c++draft/thread.condition.condvar)
- [ ] `condition_variable_any::wait_until` [[thread.condvarany.wait]](https://eel.is/c++draft/thread.condvarany.wait), [[thread.condvarany.intwait]](https://eel.is/c++draft/thread.condvarany.intwait)
- [ ] `counting_semaphore::try_acquire_until` [[thread.sema.cnt]](https://eel.is/c++draft/thread.sema.cnt)
- [ ] `future::wait_until` [[futures.unique.future]](https://eel.is/c++draft/futures.unique.future)
- [ ] `shared_future::wait_until` [[futures.shared.future]](https://eel.is/c++draft/futures.shared.future)

Remarks:
- We should _not_ reject non-clock types in `time_point`, per [P2212R2](https://wg21.link/p2212r2).
- `is_clock_v` is a C++20 feature, but most of affected components have been present before C++20. So we should either
- guard the `static_assert`'s with `_LIBCPP_STD_VER >= 20`, or
- create an equivalent internal variable template and use it in `static_assert`'s before C++20.

Contributor guide

Open the contributing guide

Research direction

Start by reading P0355R7 and the linked standard clauses, then inspect the listed libc++ multi-threading APIs that accept a Clock. Confirm the intended C++20 behavior and compatibility approach for earlier standards. Done means the affected APIs reject misused Clock types while time_point remains unrestricted, with coverage across the listed components.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.