8 Commits

Author SHA1 Message Date
Norman Feske
84eb264786 util/attempt.h: mark 'Attempt' types as nodiscard
This catches bugs early on. E.g., when leaving an 'Allocation'
unused, it gets immediately deallocated, which is most probably not
intended. For regular 'Attempt' objects, this change encourages
the proper propagation of errors, or at least the logging of unexpected
conditions.

Fixes #5513
2025-04-10 14:55:21 +02:00
Norman Feske
73d6171850 util/attempt.h: make 'Attempt' printable 2025-04-10 14:55:20 +02:00
Norman Feske
fee2f354dc util/attempt.h: introduce 'Ok' type
This type alleviates the need to re-introduce custom '*_ok' types
whenever a result can be an error but no value.
2025-04-10 14:55:20 +02:00
Norman Feske
2dfaeab7c2 util/attempt.h: add 'Unique_attempt' utility
The new variant combines the attempt with unique-pointer semantics
and is thereby usable for returning non-copyable objects such as
RAM 'Allocation'.

Issue #5502
2025-04-10 14:27:21 +02:00
Norman Feske
5e862b2cd3 base/include: use C++20 function template syntax
Issue #5227
2024-05-29 09:18:12 +02:00
Johannes Schlatow
5aa0fea29b base: pass lambdas by reference in util/attempt.h
genodelabs/genode#4393
2022-02-15 10:16:51 +01:00
Johannes Schlatow
b821776b0d base: add == operator to util/attempt.h
This simplifies testing for early return conditions for which the use of
lambdas would be quite noisy.

genodelabs/genode#4393
2022-02-15 10:16:51 +01:00
Norman Feske
959bcae557 base: add util/attempt.h utility
Fixes #4322
2021-11-29 15:10:52 +01:00