-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not use target<> to check if two std::function are equal #49
Labels
Comments
It works correctly. Doing debugger.StepInto doesn’t magically wait until
the step finishes, so there are 5 callbacks registered.
…On Wed, 8 May 2019 at 13:07, Chenzs108 ***@***.***> wrote:
https://github.com/x64dbg/GleeBug/blob/cd01d22686028a1d23735a24771aac533390f1e2/GleeBug/Debugger.Thread.cpp#L42-L56
I run a test with following code, taget<void()> always return nullptr. So
I can't use this to check if two std::function are equal.
#include <vector>
#include <functional>
typedef std::function<void()> StepCallback;
std::vector<StepCallback> stepCallbacks;
void StepInto(const StepCallback& cbStep)
{
auto target = cbStep.target<void()>();
for (const auto& cb : stepCallbacks)
{
// always get null
if (target == cb.target<void()>())
{
puts("duplicate StepInto callback detected!");
return;
}
}
stepCallbacks.push_back(cbStep);
}
void fun1() {}
void fun2() {}
int main()
{
StepInto(fun1);
StepInto(fun1);
StepInto(fun2);
StepInto([]() {});
StepInto(std::bind([]() {}));
return 0;
}
output:
duplicate StepInto callback detected!
duplicate StepInto callback detected!
duplicate StepInto callback detected!
duplicate StepInto callback detected!
According to cppreference
<https://en.cppreference.com/w/cpp/utility/functional/function/target>,
the template type of target<> seems very strict. Or there is something
wrong with my test?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#49>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASYFGK2WMIUUXXE4QOWLKDPUKX5ZANCNFSM4HLQWFMA>
.
|
But if |
Probably when this was written for Visual Studio 2013 the standard wasn't followed and everything was working... If you know some other way to check if two std::functions call the same function it would be appreciated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GleeBug/GleeBug/Debugger.Thread.cpp
Lines 42 to 56 in cd01d22
I run a test with following code,
taget<void()>
always returnnullptr
. So I can't use this to check if twostd::function
are equal.output:
According to cppreference, the template type of
target<>
seems very strict. Or there is something wrong with my test?The text was updated successfully, but these errors were encountered: