{"provider_name":"Hatena Blog","height":"190","title":"std::shared_ptr\u578b\u3068->*\u6f14\u7b97\u5b50\u3068std::invoke\u95a2\u6570","author_name":"yohhoy","categories":["C++"],"provider_url":"https://hatena.blog","published":"2022-08-11 00:00:00","width":"100%","description":"C++\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u578bstd::shared_ptr<T>\u3067\u306f->*\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u63d0\u4f9b\u3057\u306a\u3044\uff08\u6ce8\uff1a->\u306f\u3042\u308b\u3088\uff09\u3002 #include <memory> struct X { int mf(); }; // \u30e1\u30f3\u30d0\u95a2\u6570\u30dd\u30a4\u30f3\u30bf int (X::*pmf)() = &X::mf; // (\u901a\u5e38)\u30dd\u30a4\u30f3\u30bf\u578b X* p = new X; p->mf(); // OK (p->*pmf)(); // OK // std::shared_ptr\u578b std::shared_ptr<X> sp{ p }; sp->mf(); // OK (sp->*pmf)(); // NG! (s\u2026","author_url":"https://blog.hatena.ne.jp/yohhoy/","image_url":null,"url":"https://yohhoy.hatenadiary.jp/entry/20220811/p1","type":"rich","version":"1.0","blog_title":"yohhoy\u306e\u65e5\u8a18","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyohhoy.hatenadiary.jp%2Fentry%2F20220811%2Fp1\" title=\"std::shared_ptr\u578b\u3068-&gt;*\u6f14\u7b97\u5b50\u3068std::invoke\u95a2\u6570 - yohhoy\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","blog_url":"https://yohhoy.hatenadiary.jp/"}