2
0
mirror of https://github.com/boostorg/scope.git synced 2026-02-02 21:12:17 +00:00
Commit Graph

150 Commits

Author SHA1 Message Date
Andrey Semashev
8321450aca Improved docs for unallocated_resource.
Expanded on the requirements for resource types and values supported by
unallocated_resource.

Added a note in the INVALID_HANDLE_VALUE example that says it relies on
MSVC extension and other compilers may not accept it.
boost-1.85.0 boost-1.85.0.beta1
2024-03-12 15:12:10 +03:00
Andrey Semashev
1a1dcd8817 Added a test for unallocated_resource with INVALID_HANDLE_VALUE on Windows. 2024-03-12 14:25:42 +03:00
Andrey Semashev
d18cc5fde7 Mention _read for reading from fds on Windows. 2024-03-08 02:33:49 +03:00
Andrey Semashev
17023298dd Updated URLs in README.md. 2024-02-07 14:11:10 +03:00
Andrey Semashev
0da459f549 Updated changelog. 2024-02-07 14:02:57 +03:00
Andrey Semashev
db29667f84 Improved scope guard docs. 2024-02-07 13:52:25 +03:00
Andrey Semashev
d68ee383b0 Improved library description. 2024-02-07 02:08:51 +03:00
Andrey Semashev
3da27e413f Added library metadata. 2024-02-07 02:05:39 +03:00
Andrey Semashev
c8a05799c3 Corrected make_default return type in fd_resource_traits example.
Closes https://github.com/Lastique/scope/issues/18.
2024-02-06 20:50:25 +03:00
Andrey Semashev
052f3ad41f Added missing return in get_random_bytes example in the docs. 2024-02-06 15:36:52 +03:00
Andrey Semashev
3aa8d4fc00 Added gcc-13 CI job. 2024-02-06 00:33:22 +03:00
Andrey Semashev
622a37492d Updated C++23 flags for clang-17 in CI config. 2024-02-06 00:13:25 +03:00
Andrey Semashev
a0c5ebf58f Reduced CI job timeouts. 2024-02-05 23:58:59 +03:00
Andrey Semashev
9d15c42d82 Further tweaks for the CI scripts. 2024-02-05 18:33:49 +03:00
Andrey Semashev
ab1ed91983 Fix CI script for the case when the library is part of Boost tree. 2024-02-05 18:24:30 +03:00
Andrey Semashev
fc3caba128 Remove snapshot directory once not needed. 2024-02-05 17:51:49 +03:00
Andrey Semashev
56a3acc6e4 Replaced actions/checkout usage with manual download commands.
This fixes the deprecation warnings for actions/checkout@v3. actions/checkout@v4
is not functional because of the upstream bug:

https://github.com/actions/checkout/issues/1590
2024-02-05 16:13:16 +03:00
Andrey Semashev
d4d5d36255 Removed Conan and vcpkg projects.
Conan and vcpkg projects were added for the purpose of Boost review,
and now it's done. The library will be packaged as part of Boost.
2024-02-05 02:55:16 +03:00
Andrey Semashev
f4abde30e2 Move MSVC C4702 warning silencing past includes. 2024-02-05 00:47:51 +03:00
Andrey Semashev
0cfc01818c Disabled MSVC warning C4702: unreachable code.
This warning is triggered by tests that throw exceptions and then check
that the code that follows is not reached.
2024-02-05 00:35:50 +03:00
Andrey Semashev
183715b90f Disable warnings for auxiliary definitions on unique_fd test. 2024-02-05 00:19:09 +03:00
Andrey Semashev
127c3aaa4e Enabled warnings-as-errors for tests. 2024-02-05 00:03:54 +03:00
Andrey Semashev
8861d0297d Avoid calling unique_resource_data member function in a catch block of unique_resource_data ctor. 2024-02-04 23:25:43 +03:00
Andrey Semashev
75ac159ab6 Fixed operator-> example for unique_resource. 2024-02-04 23:23:24 +03:00
Andrey Semashev
9ea2a7264a Added a missing comma. 2024-02-04 21:17:14 +03:00
Andrey Semashev
16bbac4980 Improved unique_resource docs. 2024-02-04 21:15:23 +03:00
Andrey Semashev
45317772d1 Removed support for "reduced" resource traits in unique_resource.
The support required to be permissive wrt. is_allocated being callable
with a resource argument. This could lead to unexpected behavior, where
the user provided a seemingly conforming resource traits but
unique_resource would still reject them for some reason (e.g. if
is_allocated is not callable with the const resource value, as tested
by unique_resource) and work in "reduced" resource traits mode. This
would change the behavior of the APIs that accept resource values as
an argument (e.g. constructing unique_resource with a resource value
would always produce an object in the allocated state, while the user
would expect it to depend on the resource value).

Removing the support for "reduced" resource traits makes the behavior
more predictable. If the user specified resource traits, it either
compiles and works according to the resource traits, or fails to compile
if the resource traits are somehow not conforming.

The support for customizing default-constructed resource value is not
important enough. It can be worked around by either implementing proper
resource traits, or by specifying the default value in
make_unique_resource_checked.

Additionally, modified unallocated_resource to relax the argument type
of is_allocated and the types of the unallocated values. This can be
useful when the types of the unallocated resource values don't match
the actual resource type (e.g. std::nullptr_t vs. typed pointers).
2024-02-04 19:32:24 +03:00
Andrey Semashev
7167bce99a Don't call reset() in unique_resource destructor, call the deleter directly.
This avoids potentially assigning the default to the resource value, which
may be expensive and is pointless, as the resource is about to be destroyed
anyway.
2024-02-04 01:46:07 +03:00
Andrey Semashev
adf827b190 Docs improvements.
Removed Boost.ScopeExit from the table on the front page. Comparison with
Boost.ScopeExit is in a separate section, so this table duplicated it
to some degree and detracted focus from introducing Boost.Scope.

Added an example with unique_resource to the front page.

Other wording and example improvements.
2024-02-03 21:08:05 +03:00
Andrey Semashev
3914e2fabd Revert "Switched to actions/checkout@v4 to avoid CI deprecation warnings."
This reverts commit a8750d563f.

checkout@v4 doesn't work on ubuntu:16.04 and ubuntu:18.04 images:

https://github.com/actions/checkout/issues/1590
2024-02-02 13:38:45 +03:00
Andrey Semashev
a8750d563f Switched to actions/checkout@v4 to avoid CI deprecation warnings. 2024-02-02 13:27:37 +03:00
Andrey Semashev
18ac09b864 Add a link to an article re. different values for unallocated Windows handles. 2024-02-02 06:08:09 +03:00
Andrey Semashev
05bf32daa5 Added an example of using set_active with a runtime value. 2024-02-02 02:42:17 +03:00
Andrey Semashev
f781fd71c7 Improved scope guard examples in docs. 2024-02-01 02:52:09 +03:00
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
bb295bcd77 Consistently use "unallocated" term to refer to a unique_resource in an unallocated state. 2024-01-31 01:39:32 +03:00
Andrey Semashev
e595286ad3 Converted typedefs to using type aliases.
One person during review complained that the library implementation
used typedefs instead of C++11 using type aliases. Not an essential
difference, but if it helps code readability, let it be.
2024-01-31 01:11:01 +03:00
Andrey Semashev
080e8100f1 Made formatting more consistent in examples. 2024-01-30 11:43:59 +03:00
Andrey Semashev
989676edc1 Write strings in CSV format in the examples in the docs.
This makes the final flush of the file stream actually necessary.
2024-01-30 11:40:30 +03:00
Andrey Semashev
7616f0b944 Added a new set of examples on the front page.
The new row of examples illustrate explicit deactivation of the scope
guards, as opposed to automatic failure detection via scope_fail.

Also improved the other examples to look more realistic.

Closes https://github.com/Lastique/scope/issues/13.
2024-01-30 03:32:54 +03:00
Andrey Semashev
012104819f Improved comment. 2024-01-28 23:43:22 +03:00
Andrey Semashev
8c985b565c Changed behavior of unique_resource constructor to be non-destructive.
If the resource type is nothrow move-constructible and the deleter type
is not, and the deleter's copy constructor throws during unique_resource
move constructor, then move the move-constructed resource back to the
original object instead of invoking the deleter on it. This leaves the
move source in its original state rather than in unallocated state,
which means unique_resource move constructor now provides strong
exception guarantee.
2024-01-28 23:27:53 +03:00
Andrey Semashev
6f2adf3988 Made unique_resource::reset() implementation slightly more efficient. 2024-01-28 18:50:54 +03:00
Andrey Semashev
7be5037875 Simplified unique_resource swap implementation. 2024-01-28 18:50:54 +03:00
Andrey Semashev
eca047bf40 Updated discussion re. swap implementation on unique_resource. 2024-01-28 15:50:32 +03:00
Andrey Semashev
10d22551b2 Moved caveats of capturing by reference to a separate section. 2024-01-28 04:36:52 +03:00
Andrey Semashev
56afb11dbd Added an example showing scope_exit/scope_success/scope_fail usage. 2024-01-28 04:11:45 +03:00
Andrey Semashev
a9bb776763 Added a note about resource traits being preferred over make_unique_resource_checked. 2024-01-28 01:47:26 +03:00
Andrey Semashev
84be26e1a2 Use boost::core::functor for simplified CloseHandle deleter in the docs. 2024-01-27 20:36:13 +03:00
Andrey Semashev
ecb7d7c9cd Added comparison with Library Fundamentals TS components in the docs.
Closes https://github.com/Lastique/scope/issues/5.
2024-01-27 20:35:54 +03:00