{"id":195,"date":"2011-06-10T08:58:27","date_gmt":"2011-06-09T23:58:27","guid":{"rendered":"http:\/\/daily.belltail.jp\/?p=195"},"modified":"2011-06-11T14:59:56","modified_gmt":"2011-06-11T05:59:56","slug":"c0x%e5%8f%af%e5%a4%89%e9%95%b7%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e5%bc%95%e6%95%b0%e3%81%af%e5%86%8d%e5%b8%b0%e3%81%a7%e3%81%8a%e3%81%84%e3%81%97%e3%81%8f%e3%81%84%e3%81%9f","status":"publish","type":"post","link":"https:\/\/daily.belltail.jp\/?p=195","title":{"rendered":"(C++0x)\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306f\u518d\u5e30\u3067\u304a\u3044\u3057\u304f\u3044\u305f\u3060\u304d\u307e\u3057\u3087\u3046"},"content":{"rendered":"<p>C++0x\u3067\u5c0e\u5165\u3055\u308c\u308b\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\uff0c\u4fbf\u5229\u3067\u3059\u306d\uff0e<br \/>\n\u50d5\u306f\u9759\u7684\u306a\u306e\u304c\u5927\u597d\u304d\u306a\u306e\u3067\uff0e<\/p>\n<p>\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306e\u4f55\u304c\u304a\u3044\u3057\u3044\u304b\u3068\u3044\u3046\u3068\uff0c\u4f8b\u3048\u3070\u73fe\u5728\u306eboost::tuple\u306fT0\u304b\u3089T9\u307e\u3067\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u5b9f\u88c5\u3057\u3066\u308b\u306e\u3067\u8981\u7d20\u6570\u306f10\u4ee5\u4e0b\u306b\u9650\u5b9a\u3055\u308c\u307e\u3059\u304c\uff0cC++0x\u306b\u7528\u610f\u3055\u308c\u308bstd::tuple\u306f\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3067\u5b9f\u88c5\u3055\u308c\u308b\u306e\u3067\uff0c\u539f\u7406\u7684\u306b\u306f\uff0c\u7121\u9650\u306e\u8981\u7d20\u6570\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\uff0e<br \/>\n\u3053\u3053\u3067\u672c\u8cea\u7684\u306b\u91cd\u8981\u306a\u306e\u306f\uff0c\u300c\u7121\u9650\u306e\u8981\u7d20\u6570\u300d\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u3053\u3068\u3067\u306f\u306a\u304f\uff0c\u300c\u4efb\u610f\u306e\u8981\u7d20\u6570n\u306b\u304a\u3044\u3066\u4e00\u822c\u7684\u306b\u8a18\u8ff0\u3067\u304d\u308b\u300d\u3053\u3068\u3067\u3042\u308b\u70b9\u306b\u6ce8\u610f\uff0e<\/p>\n<p>\u307e\u305f\uff0c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3092\u7528\u3044\u3066\uff0c\u53ef\u5909\u9577\u5f15\u6570\u306e\u95a2\u6570\u3092\u66f8\u3051\u307e\u3059\uff0e<br \/>\n\u3053\u308c\u306f\uff0c\u3044\u308f\u3070\u300c\u578b\u5b89\u5168printf\u300d\u3092\u66f8\u3051\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\uff0e<\/p>\n<p>\u8a71\u304c\u3061\u3087\u3063\u3068\u9038\u308c\u307e\u3057\u305f\u304c\uff0c\u3058\u3083\u3042\u305d\u306e\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306f\u5b9f\u969b\u3069\u3046\u3044\u3046\u98a8\u306b\u6271\u3046\u306e\uff1f\u3068\u3044\u3046\u8a71\u3092\uff0c\u95a2\u6570\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u95a2\u3057\u3066\u3057\u307e\u3059\uff0e<br \/>\nWikipedia\u306b\u66f8\u3044\u3066\u3042\u308b\u7bc4\u56f2\u3088\u308a\u50c5\u304b\u306a\u304c\u3089\u5e83\u3044\u5185\u5bb9\uff0c\u3060\u3068\u601d\u3044\u307e\u3059\uff0e\u305f\u3076\u3093\uff0e<\/p>\n<p><!--more--><\/p>\n<p>*\u7528\u8a9e\u3092\u306f\u3063\u304d\u308a\u3055\u305b\u3068\u304d\u307e\u3057\u3087\u3046<\/p>\n<p>-\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4eee\u5f15\u6570<br \/>\n\u4f8b\u3048\u3070template&lt;class T&gt; class Hoge; \u306b\u304a\u3051\u308bT\u304c\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4eee\u5f15\u6570\u3067\u3059\uff0e<\/p>\n<p>-\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570<br \/>\n\u4f8b\u3048\u3070template&lt;class T&gt; class Hoge; \u306a\u30af\u30e9\u30b9\u5bfe\u3057\u3066Hoge&lt;int&gt; ob; \u3068\u3057\u305f\u3068\u304d\u306eint\u304c\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3067\u3059\uff0e<\/p>\n<p>-\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4eee\u5f15\u6570\u3068\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570<br \/>\n\u8a73\u7d30\u306f\u5f8c\u8ff0\u3057\u307e\u3059\u304c\uff0ctemplate&lt;class&#8230; Args&gt; void func(); \u306a\u30af\u30e9\u30b9\u306b\u304a\u3051\u308bArgs\u304c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4eee\u5f15\u6570\uff0c\u3053\u308c\u306b\u5bfe\u3057\u3066func&lt;int, double, char&gt;()\u306a\u3069\u3068\u3057\u305f\u3068\u304d\u306eint,double,char\u304c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3067\u3059\uff0e<\/p>\n<p>-\u4eee\u5f15\u6570\u30fb\u5b9f\u5f15\u6570\u30fb\u53ef\u5909\u9577\u5f15\u6570<br \/>\n\u300c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u300d\u3092\u4ed8\u3051\u306a\u304b\u3063\u305f\u3089\uff0c\u95a2\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u306e\u610f\u5473\u3067\u8a00\u3063\u3066\u307e\u3059\uff0e<br \/>\nvoid func(int a);\u306a\u95a2\u6570\u306ea\u304c\u4eee\u5f15\u6570\uff0c\u547c\u3073\u51fa\u3057func(100);\u306e100\u304c\u5b9f\u5f15\u6570\u2026\u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u3059\uff0e<\/p>\n<p>*\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570\u306e\u5b9a\u7fa9<\/p>\n<p>\u8a73\u7d30\u306f\u4ed6\u306b\u8b72\u308b\u3068\u3057\u3066\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class... Args&gt;\r\nvoid func(Args... args)\r\n{\r\n    \/\/...\r\n}\r\n\r\n\/\/const\u3092\u3064\u3051\u307e\u3057\u3087\u3046\uff0e\r\ntemplate&lt;class... Args&gt;\r\nvoid func(const Args&amp;... args)\r\n{\r\n    \/\/...\r\n}\r\n<\/pre>\n<p>&#8220;&#8230;&#8221;\u6f14\u7b97\u5b50\u304c2\u56de\u73fe\u308c\u3066\u307e\u3059\u304c\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4eee\u5f15\u6570Args\u306e\u524d\u306b\u304f\u308b\u5834\u5408\u306f&#8221;pack\u6f14\u7b97\u5b50&#8221;\uff0c\u5f8c\u306b\u304f\u308b\u5834\u5408\u306f&#8221;unpack\u6f14\u7b97\u5b50&#8221;\u3068\u547c\u3073\u307e\u3059\uff0e\u3042\u3068\u5f8c\u8ff0\u3057\u307e\u3059\u304c\u5b9f\u5f15\u6570\u306e\u5f8c\u306b\u66f8\u304f\u5834\u5408\u3082unpack\u6f14\u7b97\u5b50\u3068\u8a00\u3044\u307e\u3059\uff0e<br \/>\n\u610f\u5473\u306f\u306a\u3093\u3068\u306a\u304f\u60f3\u50cf\u3067\u304d\u308b\u3053\u3068\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<p>\u3042\u3068const\u53c2\u7167\u3067\u53d7\u3051\u53d6\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u4e0a\u306b\u66f8\u3044\u305f\u3088\u3046\u306b\u3057\u307e\u3059\uff0e<\/p>\n<p>\u3067\uff0c\u3053\u306e\u95a2\u6570\u306f<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfunc&lt;int, double, std::string&gt;(10, 10.5, std::string(&quot;hoge&quot;));\r\n<\/pre>\n<p>\u3067\u547c\u3073\u51fa\u305b\u307e\u3059\uff0e<\/p>\n<p>\u95a2\u6570\u306e\u5b9f\u5f15\u6570\u306b\u57fa\u3065\u3044\u305f\u578b\u63a8\u8ad6\u306b\u3088\u3063\u3066\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3082\u6c7a\u5b9a\u3067\u304d\u308b\u306e\u3067\uff0c\u5358\u306b\u578b\u6307\u5b9a\u3092\u7701\u7565\u3057\u3066\uff0c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfunc(10, 10.5, std::string(&quot;hoge&quot;));\r\n<\/pre>\n<p>\u3068\u3082\u66f8\u3051\u307e\u3059\uff0e<br \/>\n\u3053\u3053\u3093\u3068\u3053\u304c\u3042\u3068\u3067\u3061\u3087\u3063\u3068\u91cd\u8981\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>\u3068\u3053\u308d\u3067\u3053\u308c\u3092\u898b\u308b\u3068\uff0c\u307e\u3055\u306b(\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u308f\u306a\u3044)\u53ef\u5909\u9577\u5f15\u6570\u306e\u95a2\u6570\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b\u4f7f\u3048\u307e\u3059\u306d\uff0e<\/p>\n<p>\u307e\u305f\uff0c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3092\u4e38\u6295\u3052\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class... Args&gt;\r\nvoid func()\r\n{\r\n    \/\/...\r\n}\r\n\r\ntemplate&lt;class... Args&gt;\r\nvoid func2()\r\n{\r\n    func&lt;int, Args..., int&gt;();\r\n}\r\n\r\n\/\/func2&lt;double, double&gt;()\u3092\u547c\u3076\u3053\u3068\u306f\uff0c\u3053\u3053\u3067\u306ffunc&lt;int, double, double, int&gt;()\u3092\u547c\u3076\u3053\u3068\u3068\u540c\u3058\u306b\u306a\u308b\uff0e\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306bunpack\u6f14\u7b97\u5b50\u3092\u7528\u3044\u3066\uff0c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3092\uff0c\u4f55\u3089\u304b\u306e\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570\u306b\u307e\u308b\u3054\u3068\u6295\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p>\u9006\u306e\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class T, class... Args&gt;\r\nvoid func()\r\n{\r\n    \/\/...\r\n}\r\n\r\ntemplate&lt;class... Args&gt;\r\nvoid func2()\r\n{\r\n    func&lt;Args...&gt;();\r\n}\r\n\r\n\/\/\u3053\u3053\u3067func2&lt;int, double, float&gt;()\u3068\u3057\u305f\u3068\u304d\uff0cfunc\u306b\u304a\u3044\u3066T=int\uff0cArgs={double, float}\u3068\u306a\u308b\uff0e\r\n<\/pre>\n<p>\u3053\u306e\u8fba\u306e\u8a71\u3092\uff0c\u8a18\u4e8b\u306e\u30e1\u30a4\u30f3\u3067\u304c\u3063\u3064\u308a\u4f7f\u3044\u307e\u3059\uff0e<\/p>\n<p>\u3067\uff0c\u3053\u306e\u8a18\u4e8b\u3067\u8a71\u3059\u306e\u306f\uff0c\u300c\u3058\u3083\u3042func\u306e\u4e2d\u3067Args\u3092\u3069\u3046\u6271\u3046\u3088\uff1f\u300d\u3068\u3044\u3046\u8a71\u3067\u3059\uff0e<\/p>\n<p>*\u672c\u984c1:\u95a2\u6570\u306b(\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f\u578b\u306b\u5bfe\u5fdc\u3059\u308b)\u53ef\u5909\u9577\u5f15\u6570\u304c\u3042\u308b\u5834\u5408<\/p>\n<p>\u4f8b\u3048\u3070<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n func&lt;char, int&gt;('a', 10);\r\nfunc&lt;int, double, std::string&gt;(10, 10.5, std::string(&quot;hoge&quot;));\r\n<\/pre>\n<p>\u3068\u3044\u3046\u5f62\u3067\u547c\u3073\u51fa\u3055\u308c\u308b\u95a2\u6570\u306b\u3064\u3044\u3066\u8003\u3048\u307e\u3059\uff0e<br \/>\n\u3064\u307e\u308a\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u306b\u5bfe\u5fdc\u3059\u308b\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570func\u306b\u3064\u3044\u3066\uff0c\u305d\u306efunc\u306e\u4e2d\u3067\u5b9f\u969b\u306b\u6307\u5b9a\u3055\u308c\u305f\u578b\u3084\u5f15\u6570\u306b\u4e0e\u3048\u3089\u308c\u305f\u5024\u306b\u3069\u3046\u3084\u3063\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u304b\uff0c\u3068\u3044\u3046\u8a71\u3067\u3059\uff0e<\/p>\n<p>**\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u306e\u5404\u8981\u7d20\u3078\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044<\/p>\n<p>\u4f8b\u3048\u3070C#\u306e\u666e\u901a\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u53ef\u5909\u9577\u5f15\u6570\u306e\u6271\u3044\u65b9\u306f\u975e\u5e38\u306b\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3088\u306d\uff0e<br \/>\n\u3042\u308c\u306f\u305d\u3082\u305d\u3082\u578b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3058\u3083\u306a\u3044\u306e\u3067\u6bd4\u3079\u308b\u6642\u70b9\u3067\u3044\u3051\u306a\u3044\u306e\u3067\u3059\u304c\u305d\u308c\u3092\u627f\u77e5\u306e\u4e0a\u3067\u8a00\u3046\u3068\uff0c\u3042\u3093\u306a\u96f0\u56f2\u6c17\u3067\u5404\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3078\u9806\u6b21\u30a2\u30af\u30bb\u30b9\u3059\u308b\u65b9\u6cd5\u306f\u3042\u308a\u307e\u305b\u3093\uff0e<\/p>\n<p>\u4f55\u304c\u8a00\u3044\u305f\u3044\u304b\u3068\u3044\u3046\u3068\uff0c\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u3092\u53d7\u3051\u53d6\u3063\u305f\u95a2\u6570\u304c\uff0c\u300c\u5177\u4f53\u7684\u306b\u3069\u3093\u306a\u578b\u304c\u6307\u5b9a\u3055\u308c\u305f\u304b\u300d\u3092\u77e5\u308b\u7c21\u5358\u306a\u624b\u6bb5\u304c\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\uff0e\u3061\u306a\u307f\u306b\u6570\u3060\u3051\u306f\u7c21\u5358\u306b\u308f\u304b\u308a\u307e\u3059\uff0e<\/p>\n<p>**\u5148\u982d\u304b\u3089\u5207\u308a\u51fa\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\uff0c\u6b21\u306e\u3088\u3046\u306a\u6226\u7565\u3092\u3068\u308a\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class First, class... Rest&gt;\r\nvoid func(const First &amp;first, const Rest&amp;... rest);\r\n<\/pre>\n<p>\u3053\u3093\u306afunc\u304c\u3042\u308b\u3068\u304d\uff0c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfunc&lt;int, double, std::string&gt;(10, 10.5, std::string(&quot;hoge&quot;));\r\n\/\/func(10, 10.5, std::string(&quot;hoge&quot;));\u00a0 \/\/\u5b9f\u4f53\u5316\u53ef\u80fd\u306a\u3089\u3069\u3063\u3061\u3067\u3082\u3044\u3044\r\n<\/pre>\n<p>\u3068\u3057\u3066\u5b9f\u4f53\u5316\u3059\u308b(\u3053\u3053\u3067\u306f\u300c\u547c\u3073\u51fa\u3059\u300d\u3068\u540c\u7fa9\u3067\u3059\u306d)\u3068\uff0c\u578b\u3068\u3057\u3066\u306fFirst=int\uff0cRest={double, std::string}\u3068\u306a\u308a\uff0c\u5024\u3068\u3057\u3066\u306ffirst=10\uff0crest={10.5, std::string(&#8220;hoge&#8221;)}\u3068\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>First\u306f\u3061\u3083\u3093\u3068\u3057\u305f\u578b\u3067\u3042\u308afirst\u306f\u305d\u306e\u5024\u306a\u306e\u3067\uff0c\u3053\u308c\u306b\u5bfe\u3057\u3066\u306f\u4f55\u306a\u308a\u3068\u597d\u304d\u306a\u51e6\u7406\u3092\u884c\u3048\u307e\u3059\uff0e<br \/>\n\u578b\u5b89\u5168printf\u3060\u3068\uff0c\u5b9f\u5f15\u6570\u5024\u3092\u8868\u793a\uff0c\u3068\u3044\u3063\u305f\u5f62\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>\u4e00\u65b9\uff0c<span style=\"color: #ff0000;\">Rest\u306f\u4eee\u60f3\u7684\u306a\u578b\u306a\u306e\u3067\uff0c\u578bRest\u3084\u305d\u306e\u5024rest\u306b\u5bfe\u3057\u3066\u4f55\u3089\u304b\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093<\/span>\uff0e<br \/>\n\u3053\u308c\u3089\u306b\u5bfe\u3057\u3066\u884c\u3048\u308b\u306e\u306funpack\u3060\u3051\u3067\u3059\uff0e<br \/>\n\u3053\u308c\u304c\u524d\u8ff0\u3057\u305f\u300e\u300c\u5177\u4f53\u7684\u306b\u3069\u3093\u306a\u578b\u304c\u6307\u5b9a\u3055\u308c\u305f\u304b\u300d\u3092\u77e5\u308b\u7c21\u5358\u306a\u624b\u6bb5\u304c\u306a\u3044\u300f\u3053\u3068\u306e\u610f\u5473\u3067\u3059\uff0e<\/p>\n<p>\u3053\u3053\u3067\uff0c\u524d\u7bc0\u3067\u8a71\u3057\u305f\u5185\u5bb9\u3092\u4f7f\u3044\u307e\u3059\uff0e<br \/>\n\u3064\u307e\u308a\uff0c\u6b21\u306e\u3088\u3046\u306a\u5f62\u3067\u300c\u518d\u5e30\u547c\u3073\u51fa\u3057\u300d\u3092\u884c\u3044\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/\u518d\u5e30\u7d42\u7aef\u7528\u306e\u30c0\u30df\u30fc\r\nvoid func()\r\n{ }\r\n\r\ntemplate&lt;class First, class... Rest&gt;\r\nvoid func(const First&amp; first, const Rest&amp;... rest)\r\n{\r\n    \/\/\u307e\u305a\uff0c\u578b\u3084\u5024\u306e\u8981\u7d20\u305d\u308c\u305e\u308c\u306b\u5bfe\u3057\u3066\u884c\u3044\u305f\u3044\u5b9f\u969b\u306e\u51e6\u7406\u3092\uff0c\u578bFirst\u3084\u5024first\u306b\u5bfe\u3057\u3066\u884c\u3046\uff0e\r\n   \u00a0\/\/\u4f8b\u3048\u3070\u3053\u3053\u3067\u306f\u5024\u306e\u8868\u793a\uff0e\r\n    std::cout &lt;&lt; first &lt;&lt; std::endl;\r\n\r\n    \/\/\u518d\u5e30\u547c\u3073\u51fa\u3057\r\n    func(rest...);    \/\/\u5024\u3092unpack\u3057\u3066\u6e21\u3059\uff0e\r\n\r\n    \/\/func&lt;Rest...&gt;(rest...);   \/\/\u578b\u3082\u660e\u793a\u7684\u306bunpack\u3057\u3066\u6e21\u3057\u305f\u3089\u3060\u3081\uff01\uff01\r\n}\r\n<\/pre>\n<p>\u3053\u3046\u3059\u308b\u3068\uff0c\u518d\u5e30\u304c\u6df1\u307e\u308b\u5ea6\u306b\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u306e\u5148\u982d\u304b\u3089\u9806\u306b\uff0c\u884c\u3044\u305f\u3044\u51e6\u7406\u304c\u3067\u304d\u307e\u3059\uff0e<\/p>\n<p>\u307e\u305f\uff0c\u518d\u5e30\u306e\u672b\u7aef\u3067\u306fRest\u304c\u7a7a\u3068\u306a\u308a\uff0cfunc\u306e\u547c\u3073\u51fa\u3057\u6642\u306b\u8a72\u5f53\u95a2\u6570\u304c\u7121\u3044\u3068\u6012\u3089\u308c\u307e\u3059\uff0e<br \/>\n\u30c0\u30df\u30fc\u306e\u95a2\u6570\u306f\u3053\u308c\u3092\u62fe\u3046\u305f\u3081\u306e\u3082\u306e\u3067\u3059\uff0e<br \/>\n\u3053\u3053\u3067\u30b3\u30e1\u30f3\u30c8\u3067\u30c0\u30e1\u3068\u66f8\u3044\u305f\u3088\u3046\u306b\u578b\u6307\u5b9a\u3092\u3059\u308b\u3068\uff0c\u672b\u7aef\u307e\u3067\u306f\u3044\u3044\u306e\u3067\u3059\u304c\uff0c\u672b\u7aef\u3092\u62fe\u3046\u95a2\u6570func()\u3092\u547c\u3073\u51fa\u3059\u69cb\u6587\u3068\u3057\u3066\u306f\u4e0d\u6b63\u306a\u306e\u3067\uff0c\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<p>\u3042\u3068\u524d\u65b9\u53c2\u7167\u306b\u306f\u6c17\u3092\u3064\u3051\u307e\u3057\u3087\u3046orz<\/p>\n<p>\u3055\u3066\uff0c\u3053\u3053\u3067\u5927\u4e8b\u306a\u306e\u306f\uff0c\u3053\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u5c55\u958b\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u884c\u308f\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\uff0e<br \/>\n\u306a\u306e\u3067\u578b\u5b89\u5168\u6027\u3082\u9ad8\u3044\u3067\u3059\uff0e<br \/>\n\u524d\u8ff0\u3057\u305f\u3088\u3046\u306b\uff0cC#\u306eparams\u3067\u5b9f\u73fe\u3067\u304d\u308b\u53ef\u5909\u9577\u5f15\u6570\u306f\u3053\u308c\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\uff0e<br \/>\n\u3080\u3057\u308dC#\u306eparams\u3067\u306f\u4efb\u610f\u306e\u578b\u3092\u53d7\u3051\u53d6\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306fObject\u578b\u3078\u306e\u5909\u63db\u3092\u4f34\u3044\uff0c\u306a\u3093\u3084\u304b\u3093\u3084\u554f\u984c\u304c\u751f\u3058\u307e\u3059\u304c\uff0c<br \/>\nC++\u306e\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306b\u57fa\u3065\u304f\u53ef\u5909\u9577\u5f15\u6570\u306e\u95a2\u6570\u3067\u306f\uff0c\u578b\u306b\u5bfe\u3057\u3066\u76f4\u63a5\u500b\u5225\u306e\u51e6\u7406\u3092\u884c\u3048\u308b\u306e\u3067\u304a\u3044\u3057\u3044\u3067\u3059\uff0e<br \/>\n(\u578b\u5909\u63db\u306f\u751f\u3058\u306a\u3044\u3057\uff0c\u578b\u304c\u5fc5\u8981\u306a\u6a5f\u80fd\u3092\u6301\u3064\u304b\u3069\u3046\u304b\u306e\u9759\u7684\u306a\u30c1\u30a7\u30c3\u30af\u3082\u3067\u304d\u308b)<\/p>\n<p>\u3068\u3053\u308d\u3067\uff0c\u4e0a\u306e\u5b9f\u88c5\u306f\u3082\u3046\u3061\u3087\u3063\u3068\u5206\u304b\u308a\u3084\u3059\u304f\uff0c\u3068\u3044\u3046\u304bmeaningful\u306a\u5f62\u306b\u3067\u304d\u307e\u3059\u306d\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class T&gt;\r\nvoid func(const T&amp; t)\r\n{\r\n    std::cout &lt;&lt; t &lt;&lt; std::endl;\r\n}\r\n\r\ntemplate&lt;class First, class... Rest&gt;\r\nvoid func(const First&amp; first, const Rest&amp;... rest)\r\n{\r\n    func(first);\r\n    func(rest...);\r\n}\r\n<\/pre>\n<p>\u50d5\u306f\u3053\u3046\u66f8\u304f\u65b9\u304c\u597d\u304d\u3067\u3059\uff0e<\/p>\n<p>\u5b9f\u884c\u4f8b\u3092ideone\u306b\u304a\u3044\u3066\u3044\u307e\u3059\uff0e \u2192 <a href=\"http:\/\/ideone.com\/1iwbD\">http:\/\/ideone.com\/1iwbD<\/a><br \/>\nideone\u306fgcc4.5.1\u306a\u3093\u3067\u3059\u306d\u2026\u3042\u3068C++0x\u306e\u3068\u304d\u306fboost\u3092\u4f7f\u3048\u306a\u3044\u306a\u3069\u2026<br \/>\n\u307e\u3055\u304b\u4eca\u3055\u3089\u30d9\u30bf\u306afor\u30eb\u30fc\u30d7\u3092\u66f8\u304f\u3053\u3068\u306b\u306a\u308b\u3068\u306f\u601d\u308f\u306a\u304b\u3063\u305f\uff0e<br \/>\n\u3042\uff0c\u3053\u306eideone\u306e\u30b3\u30fc\u30c9\uff0cvec\u306e\u8981\u7d20\u6570\u304c0\u306e\u6642\u306f\u843d\u3061\u307e\u3059\u306d\uff0c\u305d\u3053\u3093\u3068\u3053\u306f\u8a31\u3057\u3066\u304f\u3060\u3055\u3044\u2026<\/p>\n<p>\u3067\uff0c\u5b9f\u969b\u306b\u3053\u306e\u7bc0\u3067\u8a00\u3063\u305f\u3088\u3046\u306a\u6280\u6cd5\u3067\u578b\u5b89\u5168\u306aprintf\u3092\u66f8\u3053\u3046\u3063\u3066\u3044\u3046\u8a71\u306f<a href=\"http:\/\/ja.wikipedia.org\/wiki\/C%2B%2B0x#.E5.8F.AF.E5.A4.89.E9.95.B7.E5.BC.95.E6.95.B0.E3.83.86.E3.83.B3.E3.83.97.E3.83.AC.E3.83.BC.E3.83.88\">C++0x &#8211; Wikipedia#\u53ef\u5909\u9577\u5f15\u6570\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/a>\u306b\u3082\u8f09\u3063\u3066\u308b\u306e\u3067\uff0c\u305d\u3061\u3089\u3082\u4f75\u305b\u3066\u3069\u3046\u305e\uff0c<\/p>\n<p>*\u672c\u984c2:\u95a2\u6570\u306b(\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f\u578b\u306b\u5bfe\u5fdc\u3059\u308b\u53ef\u5909\u9577\u306e)\u5f15\u6570\u304c\u7121\u3044\u5834\u5408<\/p>\n<p>\u3055\u3066\uff0c\u3053\u3061\u3089\u306f\u524d\u8ff0\u306e\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u306b\u5bfe\u5fdc\u3057\u305f\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308b\u95a2\u6570\u306b\u6bd4\u3079\u3066\uff0c\u5c11\u3005\u5384\u4ecb\u3068\u306a\u308a\u307e\u3059\uff0e<br \/>\n\u3068\u3044\u3046\u306e\u3082\uff0c\u5f15\u6570\u304c\u7121\u3044\u4ee5\u4e0a\uff0c\u5b9f\u5f15\u6570\u306b\u57fa\u3065\u304f\u578b\u63a8\u8ad6\u304c\u50cd\u304d\u5f97\u306a\u3044\u304b\u3089\u3067\u3059\uff0e<\/p>\n<p>\u3053\u306e\u3068\u304d\u306b\uff0c\u578b\u6307\u5b9a\u5468\u308a\u304c\u3081\u3093\u3069\u304f\u3055\u304f\u306a\u308a\u307e\u3059\uff0e<br \/>\n\u5358\u7d14\u306b\u6b21\u306e\u3088\u3046\u306b\u66f8\u304f\u3068\uff0c\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/\u3053\u306e\u30b3\u30fc\u30c9\u306f\u30a8\u30e9\u30fc\r\n\r\nvoid func()\r\n{\r\n    \/\/\u8868\u793a\u3059\u308b\u5024\u306f\u306a\u3044\u306e\u3067\uff0c\u578b\u306e\u540d\u524d\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u3087\u3046\uff0e\u51fa\u529b\u5185\u5bb9\u306f\u5b9f\u88c5\u4f9d\u5b58\u3067\u3059\uff0e\r\n    std::cout &lt;&lt; typeid(First).name() &lt;&lt; std::endl;\r\n}\r\n\r\ntemplate&lt;class First, class... Rest&gt;\r\nvoid func()\r\n{\r\n    func&lt;First&gt;();\r\n\r\n    func&lt;Rest...&gt;();\r\n    \/\/\u2191\r\n    \/\/\u5b9f\u5f15\u6570\u304c\u7121\u3044\u305f\u3081\u578b\u63a8\u8ad6\u304c\u4f7f\u3048\u305a\uff0c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9f\u5f15\u6570\u306f\u660e\u793a\u7684\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\r\n    \/\/\u305d\u3046\u3059\u308b\u3068\uff0c\u518d\u5e30\u306e\u672b\u5c3e\u306b\u305f\u3069\u308a\u7740\u3044\u3066Rest\u304c\u7a7a\u3068\u306a\u3063\u305f\u3068\u304d\uff0c\r\n    \/\/\u547c\u3073\u51fa\u3057\u8a18\u8ff0\u306b\u30de\u30c3\u30c1\u3059\u308b\u95a2\u6570\u304c\u898b\u3064\u304b\u3089\u306a\u3044\uff0e\r\n    \/\/(\u305d\u3082\u305d\u3082\u3053\u308c\u306b\u30de\u30c3\u30c1\u3059\u308b\u95a2\u6570\u306e\u5b9a\u7fa9\u81ea\u4f53\u304c\u304a\u305d\u3089\u304f\u4e0d\u53ef\u80fd\uff1f)\r\n}\r\n<\/pre>\n<p>\u30b3\u30e1\u30f3\u30c8\u4e2d\u306e\u8aac\u660e\u306b\u66f8\u3044\u305f\u3088\u3046\u306a\u7406\u7531\u3067\uff0c\u901a\u308a\u307e\u305b\u3093\uff0e<\/p>\n<p>\u3068\u3044\u3063\u3066\u3082\u5bfe\u7b56\u306f(\u308f\u3056\u308f\u3056\u65b0\u3057\u3044\u7bc0\u3067\u66f8\u304f\u307b\u3069\u3082\u306a\u3044\u304f\u3089\u3044)\u30b7\u30f3\u30d7\u30eb\u3067\uff0cFirst\u3060\u3051\u3058\u3083\u306a\u304fSecond\u3082\u7528\u610f\u3057\u307e\u3059\uff0e<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\ntemplate&lt;class First&gt;\r\nvoid func()\r\n{\r\n    std::cout &lt;&lt; typeid(First).name() &lt;&lt; std::endl;\r\n}\r\n\r\ntemplate&lt;class First, class Second, class... Rest&gt;\r\nvoid func()\r\n{\r\n    func&lt;First&gt;();\r\n    func&lt;Second, Rest...&gt;();\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u306f\u3044\u308f\u3070\u300c\u518d\u5e30\u306e\u672b\u7aef\u3067\u554f\u984c\u304c\u751f\u3058\u308b\u306a\u3089\uff0c\u672b\u7aef\u306e\u3072\u3068\u3064\u624b\u524d\u3067\u3084\u3081\u3068\u3053\u3046\u300d\u7684\u306a\u8003\u3048\u65b9\u3067\u3059\uff0e<br \/>\n\u4f55\u304c\u8d77\u3053\u3063\u3066\u308b\u304b\u306f\u7279\u306b\u8a00\u308f\u306a\u3044\u3067\u3082\u5927\u4e08\u592b\u3067\u3059\u306d\uff0e<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u3053\u3061\u3089\u3067\u3059\uff1e <a href=\"http:\/\/ideone.com\/cBzhy\">http:\/\/ideone.com\/cBzhy<\/a><\/p>\n<p>*\u74b0\u5883\u306b\u3064\u3044\u3066<\/p>\n<p>gcc\u306b\u304a\u3044\u3066\u306f\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u5468\u308a\u306f\u7d50\u69cb\u30bf\u30a4\u30e0\u30ea\u30fc\u306b\u5b9f\u88c5\u304c\u9032\u3093\u3067\u308b\u9818\u57df\u306e\u3088\u3046\u3067\uff0c\u7279\u306b\u30af\u30e9\u30b9\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u306e\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306e\u8fba\u308a\u306funimplemented\u304c\u3061\u3089\u307b\u3089\u3042\u308a\u307e\u3059\uff0e<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306e\u30b5\u30f3\u30d7\u30eb\u306f\uff0cgcc4.4.3\u3068gcc4.5.1\u3068gcc4.6.0\u3067\u306e\u305d\u308c\u305e\u308cC++0x\u30b5\u30dd\u30fc\u30c8\u3067\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\uff0e<br \/>\n\u3061\u306a\u307f\u306b4.5.1\u306fideone\u3067\u3059\uff0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C++0x\u3067\u5c0e\u5165\u3055\u308c\u308b\u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\uff0c\u4fbf\u5229\u3067\u3059\u306d\uff0e \u50d5\u306f\u9759\u7684\u306a\u306e\u304c\u5927\u597d\u304d\u306a\u306e\u3067\uff0e \u53ef\u5909\u9577\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570\u306e\u4f55\u304c\u304a\u3044\u3057\u3044\u304b\u3068\u3044\u3046\u3068\uff0c\u4f8b\u3048\u3070\u73fe\u5728\u306eboost::tuple\u306fT0\u304b\u3089T9\u307e\u3067\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5f15\u6570 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-1","tag-c"],"_links":{"self":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=195"}],"version-history":[{"count":0,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daily.belltail.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}