aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/bits/concepts.hpp15
1 files changed, 15 insertions, 0 deletions
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<typename LockableType>
+ concept lockable = basic_lockable<LockableType> && 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<bool>;
+ };
+
template<typename SuspectType>
concept allocator_like = requires(SuspectType & suspect) {
typename SuspectType::value_type;