c++ - Get object context from std::function -


i have std::function points class member function, eg, &foo:bar. std::function object record object context, eg, foo*? there way obtain context std::function object/class?

the purpose find out if unordered_multimap of functions contains function context (but not same class member function).

example;

std::unordered_multimap<int, std::function<int(int)>> callbacks;  foo* myfoo = new foo(); callbacks[1].emplace( std::bind(&foo::bar, myfoo, std::placeholders::_1) ); callbacks[1].emplace( std::bind(&foo::bar2, myfoo, std::placeholders::_1) ); // callbacks contains 2 functions same object/context. want avoid  // check context exists before inserting auto vcallbacks = callbacks.equal_range(1); (auto iter = vcallbacks.first; iter != vcallbacks.second; iter++) {     std::function<int(int)> func = iter->second;      // somehow check function object context myfoo     if (func.??? == myfoo)         // sorry cant add callback because object has registered 1 } 

no, not. cannot inspect contents of std::function in useful way.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -