{"id":35,"date":"2015-03-10T11:12:27","date_gmt":"2015-03-10T02:12:27","guid":{"rendered":"http:\/\/milennium9.godohosting.com\/wordpress\/?p=35"},"modified":"2015-03-10T11:12:27","modified_gmt":"2015-03-10T02:12:27","slug":"type_index-%ec%98%88%ec%a0%9c","status":"publish","type":"post","link":"http:\/\/milennium9.godohosting.com\/wordpress\/?p=35","title":{"rendered":"type_index \uc608\uc81c"},"content":{"rendered":"<p>std::type_index\ub97c \uc0ac\uc6a9\ud558\uba74 \ud0c0\uc785\uc744 id\ub85c \uc0ac\uc6a9\ud55c container\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"lang:default decode:true \" title=\"typeindex\">#include &lt;iostream&gt;\r\n#include &lt;unordered_map&gt;\r\n#include &lt;type_traits&gt;\r\n#include &lt;typeindex&gt;\r\n#include &lt;functional&gt;\r\n\r\nusing namespace std;\r\n\r\nunordered_map&lt;type_index, function&lt;void()&gt;&gt; mapType;\r\n\r\ntemplate&lt;typename T&gt;\r\nvoid WhatIsThis(T) {\r\n\tmapType[typeid(T)]();\r\n}\r\nint main() {\r\n\tmapType.emplace(typeid(int), []{cout &lt;&lt; \"this is int\" &lt;&lt; endl;});\r\n\tmapType.emplace(typeid(float), []{cout &lt;&lt; \"this is float\" &lt;&lt; endl;});\r\n\tmapType.emplace(typeid(double), []{cout &lt;&lt; \"this is double\" &lt;&lt; endl;});\r\n\tmapType.emplace(typeid(const char*), []{cout &lt;&lt; \"this is const char*\" &lt;&lt; endl;});\r\n\t\r\n\tWhatIsThis(1);\r\n\tWhatIsThis(0.5f);\r\n\tWhatIsThis(0.5);\r\n\tWhatIsThis(\"Hello world\");\r\n\treturn 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>std::type_index\ub97c \uc0ac\uc6a9\ud558\uba74 \ud0c0\uc785\uc744 id\ub85c \uc0ac\uc6a9\ud55c container\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. #include &lt;iostream&gt; #include &lt;unordered_map&gt; #include &lt;type_traits&gt; #include &lt;typeindex&gt; #include &lt;functional&gt; using namespace std; unordered_map&lt;type_index, function&lt;void()&gt;&gt; mapType; template&lt;typename T&gt; void WhatIsThis(T) { mapType[typeid(T)](); } int main() { mapType.emplace(typeid(int), []{cout &lt;&lt; &#8220;this is int&#8221; &lt;&lt; endl;}); mapType.emplace(typeid(float), []{cout &lt;&lt; &#8220;this is float&#8221; &lt;&lt; endl;}); mapType.emplace(typeid(double), []{cout &lt;&lt; &#8220;this &hellip; <a href=\"http:\/\/milennium9.godohosting.com\/wordpress\/?p=35\" class=\"more-link\"><span class=\"screen-reader-text\">type_index \uc608\uc81c<\/span> \ub354\ubcf4\uae30 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0},"categories":[4],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5PypW-z","_links":{"self":[{"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/35"}],"collection":[{"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=35"}],"version-history":[{"count":1,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":36,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions\/36"}],"wp:attachment":[{"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/milennium9.godohosting.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}