The compiler ICEs when tests for unallocated_resource helper are
compiled. It isn't clear what upsets the compiler, but changing the
unique_resource constructor that is being called works around the
problem.
Since unallocated_resource is still usable, we're not disabling it
for this compiler and just update the test. Users encountering ICEs
will have to deal with them on their end (upgrading the compiler might
be one way to do it).
https://developercommunity.visualstudio.com/t/ICE-when-compiling-NTTP-related-BoostSc/10922599
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).
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.
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.
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.
Also hidden these conditions from docs since they now involve symbols
from namespace detail.
Added test for noexcept(reset()).
Closes https://github.com/Lastique/scope/issues/7.
This reflects the decay type trait that is used in make_unique_resource_checked
and is needed to support references to functions for deleters.
Added tests for unique_resource type deductions involving references
to functions.