use *this as std::shared_ptr <p>here is a "chess++" problem that I'm facing wright now with my nested class, although it may look like some joke, it's not a joke but real problem which I want to either solve or change the way to achieve the same thing in my project.</p> <pre><code>#include &lt;map&gt; #include &lt;memory&gt; #include &lt;iostream&gt; #include &lt;sigc++/signal.h&gt; class foo { public: struct bar; typedef sigc::signal&lt;void, std::shared_ptr&lt;bar&gt;&gt; a_signal; struct bar { bar() { some_signal.connect(sigc::mem_fun(*this, &amp;foo::bar::func)); } void notify() { some_signal.emit(this); // how to ?? } void func(std::shared_ptr&lt;foo::bar&gt; ptr) { std::cout &lt;&lt; "you haxor!" &lt;&lt; std::endl; // use the pointer ptr-&gt; } a_signal some_signal; }; std::map&lt;int, std::shared_ptr&lt;bar&gt;&gt; a_map; }; int main() { std::shared_ptr&lt;foo::bar&gt; a_foo_bar; foo foo_instance; foo_instance.a_map.insert(std::pair&lt;int, std::shared_ptr&lt;foo::bar&gt;&gt;(4, a_foo_bar)); foo_instance.a_map.at(0)-&gt;notify(); return 0; } </code></pre> <p>What I want to do here is to emit a signal. the signal is declared as one that triggers a handler that takes a shared_ptr as an argument. the function notify() should convert *this into shared_ptr, how do I do that to make the above code run?</p>