From 2750018596e2379a868d526262ce567a7042154d Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 29 Sep 2026 10:42:57 +0200 Subject: kstd/concepts: add lockable concept --- libs/kstd/kstd/bits/concepts.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libs') diff --git a/libs/kstd/kstd/bits/concepts.hpp b/libs/kstd/kstd/bits/concepts.hpp index af9f6d2c..d40b8de2 100644 --- a/libs/kstd/kstd/bits/concepts.hpp +++ b/libs/kstd/kstd/bits/concepts.hpp @@ -29,6 +29,21 @@ namespace kstd::bits lockable.unlock(); }; + //! Requirements on a basic lockable object. + //! + //! Given: + //! - @p L, a class type + //! - @p l, an instance of @p L + //! + //! @p L is said to be **lockable**, iff. it is a basic_lockable and the following expression is valid: + //! - @p l.try_lock(); + template + concept lockable = basic_lockable && requires(LockableType & lockable) { + //! Try to lock the lockable object, returning @p true iff. the locking was successful, @p false + //! otherwise. + { lockable.try_lock() } -> std::same_as; + }; + template concept allocator_like = requires(SuspectType & suspect) { typename SuspectType::value_type; -- cgit v1.2.3