Skip to content

Allow capturing from a raw pointer#896

Merged
kennykerr merged 5 commits intomasterfrom
capture
Mar 23, 2021
Merged

Allow capturing from a raw pointer#896
kennykerr merged 5 commits intomasterfrom
capture

Conversation

@oldnewthing
Copy link
Member

This saves the hassle of having to wrap the raw pointer inside a temporary com_ptr or a lambda.

This PR is in two commits. The first is a refactor so that all the capturing functions funnel through to a single capture_to.

The second is the one that adds capture_to support for capturing from a raw pointer.

oldnewthing and others added 5 commits March 19, 2021 21:06
The logic for deciding how to capture things is now moved
into capture_to, so that we don't have to repeat it four times:
(Free function vs member function) x (capture vs try_capture).
This saves the hassle of having to wrap the raw pointer
inside a temporary com_ptr or a lambda.
If O can have "pointer to members", then it's not a function pointer.
This forces the class to use generalized function pointers,
even if it would have used optimized function pointers had
it been complete.

Switch to std::is_class_v and std::is_union_v to detect that
a type can have member functions.
@kennykerr kennykerr merged commit ede68ed into master Mar 23, 2021
@kennykerr kennykerr deleted the capture branch March 23, 2021 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants