{"id":55,"date":"2009-04-05T22:09:52","date_gmt":"2009-04-05T14:09:52","guid":{"rendered":"http:\/\/www.genepeng.com\/?p=55"},"modified":"2009-04-05T22:09:52","modified_gmt":"2009-04-05T14:09:52","slug":"make_pair","status":"publish","type":"post","link":"https:\/\/www.genepeng.com\/index.php\/55","title":{"rendered":"make_pair"},"content":{"rendered":"<p>\u5173\u4e8emake_pair(1,   &#8220;Test&#8221;)\u4e3a\u4ec0\u4e48\u6709\u9519\uff1a  <\/p>\n<p>  1   \u5148\u58f0\u660e\u4e00\u4e9b\u4e1c\u897f\uff1a<br \/>\n  template   &lt;typename   T1,   typename   T2&gt;<br \/>\n  struct   pair<br \/>\n  {<br \/>\n      T1   first;<br \/>\n      T2   second;<br \/>\n      \/\/     &#8230;<br \/>\n  };  <\/p>\n<p>  template   &lt;typename   T1,   typename   T2&gt;<br \/>\n  pair&lt;T1,   T2&gt;   make_pair(T1   const&amp;,   T2   const&amp;);  <\/p>\n<p>  2   \u5f53\u8c03\u7528make_pair(1,   &#8220;Test&#8221;)\u65f6  <\/p>\n<p>      2.1   \u7c7b\u578b\u63a8\u5bfc<br \/>\n              #1   T1   =   int;<br \/>\n              #2   \u7531\u4e8e&#8221;Test&#8221;\u7684\u7c7b\u578b\u662fchar   const[5]\uff0c<br \/>\n                    \u800c\u4e14\u51fd\u6570\u53c2\u6570T2   const&amp;\u662f\u5f15\u7528\uff0c<br \/>\n                    \u6240\u4ee5T2   =   char   const[5]<br \/>\n      2.2   \u5b9e\u4f8b\u5316\u51fd\u6570<br \/>\n      pair&lt;int,   char   const[5]&gt;   make_pair&lt;&gt;(int   const&amp;,   char   const   (const&amp;)[5]);  <\/p>\n<p>  3   \u5b9e\u4f8b\u5316pair&lt;int,   char   const[5]&gt;\u7c7b\u578b\u5bfc\u81f4\uff1a  <\/p>\n<p>      struct   pair&lt;&gt;<br \/>\n      {<br \/>\n          int   first;<br \/>\n          char   const   second[5];<br \/>\n          \/\/&#8230;<br \/>\n      };<br \/>\n      \u8fd9\u4e2a\u7c7b\u578b\u6839\u672c\u5c31\u4e0d\u53ef\u80fd\u7528\u6765\u751f\u6210\u5bf9\u8c61\uff0c\u56e0\u4e3a\u4f60<br \/>\n      \u65e0\u6cd5\u521d\u59cb\u5316\u5e38\u6570\u6570\u7ec4\u6210\u5458\u3002  <\/p>\n<p>  4   \u5b9e\u4f8b\u5316\u5931\u8d25\u5bfc\u81f4\u7f16\u8bd1\u9519\u8bef\uff1a<br \/>\n  template   &lt;typename   T1,   typename   T2&gt;<br \/>\n  pair&lt;T1,   T2&gt;   make_pair(T1   const&amp;   t1,   T2   const&amp;   t2)<br \/>\n  {<br \/>\n      return   pair&lt;T1,   T2&gt;(t1,   t2);     \/\/   \u65e0\u6cd5\u6784\u9020pair\u5bf9\u8c61\uff0c\u89c1\u4e0a\u97623\u7684\u63cf\u8ff0<br \/>\n                    ^^^^^^^^^^^^^^^^^^^^^<br \/>\n  }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8emake_pair(1, &#8220;Test&#8221;)\u4e3a\u4ec0\u4e48\u6709\u9519\uff1a 1 \u5148\u58f0\u660e\u4e00\u4e9b\u4e1c\u897f\uff1a template &lt;typename T1, typename T2&gt; struct pair { T1 first; T2 second; \/\/ &#8230; }; template &lt;typename T1, typename T2&gt; pair&lt;T1, T2&gt; make_pair(T1 const&amp;, T2 const&amp;); 2 \u5f53\u8c03\u7528make_pair(1, &#8220;Test&#8221;)\u65f6 2.1 \u7c7b\u578b\u63a8\u5bfc #1 T1 = int; #2 \u7531\u4e8e&#8221;Test&#8221;\u7684\u7c7b\u578b\u662fchar const[5]\uff0c \u800c\u4e14\u51fd\u6570\u53c2\u6570T2 const&amp;\u662f\u5f15\u7528\uff0c \u6240\u4ee5T2 = char const[5] 2.2 \u5b9e\u4f8b\u5316\u51fd\u6570 pair&lt;int, char const[5]&gt; make_pair&lt;&gt;(int const&amp;, &#8230; <a title=\"make_pair\" class=\"read-more\" href=\"https:\/\/www.genepeng.com\/index.php\/55\" aria-label=\"More on make_pair\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,3],"tags":[29],"_links":{"self":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/55"}],"collection":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":2,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":57,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions\/57"}],"wp:attachment":[{"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.genepeng.com\/index.php\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}