* Make the library modular usable.
* Switch to library requirements instead of source. As source puts extra source in install targets.
* Add missing import-search for cconfig/predef checks.
* Add requires-b2 check to top-level build file.
* Update dependencies.
* Bump B2 require to 5.2
* Remove repeated import-search.
* Move inter-lib dependencies to a project variable and into the build targets.
* Adjust doc build to avoid boost-root references.
* Update build deps.
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.
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).
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.
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.
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.
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.
A new unallocated_resource class template allows to automatically generate
resource traits from one or more unallocated resource values.
The idea for a more compact unique_resource declaration was given
by Janko Dedic in his review.
Although it was there to make the scope guards intergace-compatible with
the TS, the review conclusion indicated that strict conformance with
the TS is not a desired goal. So remove the release() method and keep
set_active() as the way to (de)activate the scope guard.
Use an `equal_files` function as an example to demonstrate `unique_resource`
usage. This is less controversial than the previously used `write_string`
function, as it should not raise concerns about general correctness of the
function in case of failure (i.e. whether it is correct to leave the file
partially written in case of failure).
Additionally, after code refactoring, the actual interesting part of the
example became smaller, which allowed to remove most of the `equal_files`
implementation from the second and third code samples.
Closes https://github.com/Lastique/scope/issues/9.
Apparently, the Library Fundamentals TS does permit pointers to functions
in scope guards (via the "function object type" definition in the standard),
so instead of taking the effort to preserve the function references decay
those to pointers to functions.
Updated docs and tests.
Scope guard factory functions used to generate scope guards with incorrect
action and condition types if the factory was called with function
references. The scope guard template arguments used to be function types
instead of references to functions.
Also, deduction guides used to decay the arguments, which would produce
scope guards with pointers to functions in template arguments. Although
this worked, formally only references to functions are supported. So
changed the deduction guides to produce references to functions.
Updated docs and tests.
Fixes https://github.com/Lastique/scope/issues/6.
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.
This avoids a potential confusion that the object in the examples
is a scope guard, as scope guards have the set_active method.
Closes https://github.com/Lastique/scope/issues/1.