2
0
mirror of https://github.com/boostorg/scope.git synced 2026-01-19 16:52:08 +00:00

11 Commits

Author SHA1 Message Date
Andrey Semashev
d53d4f43af Enforced correctness checks for resource traits, improved docs.
Instead of silently switching to the unique_resource implementation
based on the "allocated" flag if the resource traits don't conform
to the requirements, issue hard compilation errors. This should better
protect against mistakes, where the user assumes unique_resource
behaves as if it is using the resource traits while it actually doesn't.

Improved documentation of requirements for resource traits and documented
the "reduced" form of resource traits, where the traits only provide
the default resource value but otherwise don't change unique_resource
behavior.
2024-01-31 04:52:12 +03:00
Andrey Semashev
b0117a4b2e Renamed scope_final to defer_guard and BOOST_SCOPE_FINAL to BOOST_SCOPE_DEFER.
This follows the suggestion by Peter Dimov during the review.
2024-01-19 01:13:26 +03:00
Andrey Semashev
80d26d6909 Prevent default-construction of function pointers.
Default- and value-constructed pointers to functions are not callable,
and therefore are not accepted as default-constructible condition
function objects and deleters.

Closes https://github.com/Lastique/scope/issues/14.
2023-12-17 19:16:08 +03:00
Andrey Semashev
04f61ef8c8 Corrected a comment. 2023-11-27 00:46:36 +03:00
Andrey Semashev
fbfdb8a494 Merged scope_check into scope_exit.
As suggested by Peter Dimov on boost-dev ML, scope_check functionality
is merged into scope_exit. Thus scope_exit now has an optional condition
function object, which by default always returns true. If a custom
function object is specified, scope_exit works equivalently to the
previous scope_check, i.e. calls the condition function object to check
whether the action function object needs to be called.
2023-10-14 19:23:32 +03:00
Andrey Semashev
c5635f21cc Implemented scope_check and added support for arbitrary fail conditions.
The new scope_check scope guard is a generalization of scope_success and
scope_fail and allows specifying arbitrary conditions for executing the
scope exit action. The scope_success and scope_fail have been
reimplemented in terms of scope_check and now also support arbitrary
fail conditions.

Added exception_checker and error_code_checker conditions for testing
for an exception being thrown and for an error code, respectively.
scope_success and scope_fail use exception_checker by default.

Added tests for the new components.
2023-03-26 21:02:11 +03:00
Andrey Semashev
6c2649c12e Added tests for preventing construction of reference resource wrappers from rvalues. 2023-03-06 04:49:52 +03:00
Andrey Semashev
f3cfd937f6 Updated license headers. 2023-02-24 19:30:55 +03:00
Andrey Semashev
18b135804a Added support for default_resource keyword. 2023-02-22 01:38:35 +03:00
Andrey Semashev
928160b613 Added unique_posix_fd. Fixed unique_resource traits support. Added tests. 2023-02-12 20:13:53 +03:00
Andrey Semashev
9f55473af2 Initial commit. 2023-01-10 02:18:35 +03:00