Add support for accessing the underlying pointer type via a dispatch #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #79,
proxy
allows invocation of a dispatch to fallback to a default implementation without the context of the underlying entity. However, it is not enough for the scenarios where a concrete dispatch wants to observe the pointer without dereferencing it. One example is that when aproxy
holds an instance ofstd::shared_ptr
, there is currently no API to create anstd::weak_ptr
from it.In this change, another fallback of dispatch invocation was introduced. Specifically, for a dispatch type
D
, one of its declared overload typeO
(R(Args...) noexcept(NE)
), and a pointer typeP
, overload resolution will happen in the following sequence:std::is(_nothrow)_invocable_r_v<R, typename D::template invoker<target-type-of<P>>, target-type-of<P>&, Args...>
istrue
, or otherwisestd::is(_nothrow)_invocable_r_v<R, typename D::template invoker<const P>, const P&, Args...>
istrue
, or otherwisevoid
and call the invoker without any context from the proxy object whenstd::is(_nothrow)_invocable_r_v<R, typename D::template invoker<void>, Args...>
iftrue
, or otherwiseThis change is covered by a new unit test case
ProxyInvocationTests.TestObserverDispatch
.Fixes #84