{"id":120467,"date":"2026-10-31T19:24:29","date_gmt":"2026-10-31T11:24:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/120467.html"},"modified":"2026-10-31T19:24:29","modified_gmt":"2026-10-31T11:24:29","slug":"c%e7%9a%84decltype%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/120467.html","title":{"rendered":"c++\u7684decltype\u662f\u4ec0\u4e48"},"content":{"rendered":"<h2>\u4e00\u3001decltype \u662f\u4ec0\u4e48&#xff1f;<\/h2>\n<p>decltype \u662f C&#043;&#043;11 \u5f15\u5165\u7684\u7c7b\u578b\u63a8\u5bfc\u5173\u952e\u5b57\u3002<\/p>\n<p>\u5b83\u7684\u4f5c\u7528\u662f&#xff1a;\u6839\u636e\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u63a8\u5bfc\u51fa\u8be5\u8868\u8fbe\u5f0f\u5bf9\u5e94\u7684\u7c7b\u578b&#xff0c;\u5e76\u5c06\u5176\u4f5c\u4e3a\u53d8\u91cf\u3001\u51fd\u6570\u8fd4\u56de\u503c\u6216\u5176\u4ed6\u58f0\u660e\u7684\u7c7b\u578b\u3002<\/p>\n<p>\u57fa\u672c\u8bed\u6cd5&#xff1a;<\/p>\n<p>decltype(expression) variable;<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a) b &#061; 20;<\/p>\n<p>\u6b64\u65f6 decltype(a) \u63a8\u5bfc\u51fa int&#xff0c;\u56e0\u6b64\u76f8\u5f53\u4e8e&#xff1a;<\/p>\n<p>int b &#061; 20;<\/p>\n<p>\u6ce8\u610f&#xff1a;decltype \u53ea\u63a8\u5bfc\u7c7b\u578b&#xff0c;\u4e0d\u4f1a\u6267\u884c\u8868\u8fbe\u5f0f\u3002<\/p>\n<p>\u8fd9\u91cc\u53ef\u80fd\u4f1a\u611f\u89c9\u5927\u8d39\u5468\u7ae0\u53ea\u662fdecltype(a)\u66ff\u4ee3\u4e86int<\/p>\n<h3>\u4e8c\u3001\u4e3a\u4ec0\u4e48\u9700\u8981 decltype&#xff1f;<\/h3>\n<p>\u6838\u5fc3\u539f\u56e0&#xff1a;\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u4e0e\u53e6\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4&#xff0c;\u4f46\u53c8\u4e0d\u60f3\u624b\u52a8\u6307\u5b9a\u7c7b\u578b\u3002<\/p>\n<h4>1. \u907f\u514d\u91cd\u590d\u4e66\u5199\u590d\u6742\u7c7b\u578b<\/h4>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<\/p>\n<p>using std::string;<br \/>\nstd::vector&lt;string&gt; vec;<\/p>\n<p>int main() {<br \/>\n    decltype(vec) vec1;<br \/>\n    decltype(vec) vec2;<br \/>\n    decltype(vec) vec3;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>vec1,vec2,vec3\u81ea\u52a8\u83b7\u5f97\u4e0e vec \u76f8\u540c\u7684\u7c7b\u578b&#xff0c;\u4e0d\u7136vec1,vec2,vec3\u6bcf\u4e2a\u90fd\u8981\u5199\u4e00\u5806\u524d\u7f00&#xff0c;\u4e5f\u633a\u9ebb\u70e6\u7684\u3002<\/p>\n<p>\u5982\u679c\u4ee5\u540e\u4fee\u6539 vec \u7684\u7c7b\u578b&#xff0c;vec1,vec2,vec3\u4e0d\u9700\u8981\u8ddf\u7740\u624b\u52a8\u4fee\u6539\u3002<\/p>\n<h4>2. \u83b7\u53d6\u8868\u8fbe\u5f0f\u771f\u6b63\u7684\u8fd4\u56de\u7c7b\u578b<\/h4>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>int a &#061; 10;<br \/>\ndouble b &#061; 3.14;<\/p>\n<p>decltype(a &#043; b) result &#061; a &#043; b;<\/p>\n<p>a &#043; b \u7684\u7ed3\u679c\u7c7b\u578b\u662f double&#xff0c;\u56e0\u6b64 result \u662f double\u3002<\/p>\n<h4>3. \u914d\u5408\u6a21\u677f\u7f16\u7a0b<\/h4>\n<p>\u8fd9\u662f decltype \u975e\u5e38\u91cd\u8981\u7684\u7528\u9014\u3002<\/p>\n<p>template&lt;typename T1, typename T2&gt;<br \/>\nauto add(T1 a, T2 b) -&gt; decltype(a &#043; b) {<br \/>\n    return a &#043; b;<br \/>\n}<\/p>\n<p>\u8fd9\u91cc&#xff1a;<\/p>\n<ul>\n<li>\n<p>T1\u3001T2 \u662f\u4e24\u4e2a\u53c2\u6570\u7684\u7c7b\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>decltype(a &#043; b) \u63a8\u5bfc\u52a0\u6cd5\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u7c7b\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>auto \u8868\u793a\u51fd\u6570\u8fd4\u56de\u7c7b\u578b\u91c7\u7528\u540e\u7f6e\u8fd4\u56de\u7c7b\u578b\u58f0\u660e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>auto result &#061; add(10, 3.14);<\/p>\n<p>\u8fd4\u56de\u7c7b\u578b\u662f double\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u9700\u8981\u5b83&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u6a21\u677f\u53c2\u6570\u7684\u7c7b\u578b\u53ef\u80fd\u4e0d\u540c&#xff0c;\u65e0\u6cd5\u63d0\u524d\u786e\u5b9a\u8fd0\u7b97\u7ed3\u679c\u7c7b\u578b\u3002decltype \u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u8868\u8fbe\u5f0f\u63a8\u5bfc\u7ed3\u679c\u7c7b\u578b\u3002<\/p>\n<h3>\u4e09\u3001decltype \u6700\u91cd\u8981\u7684\u63a8\u5bfc\u89c4\u5219<\/h3>\n<p>\u8fd9\u662f\u5b66\u4e60 decltype \u5fc5\u987b\u638c\u63e1\u7684\u90e8\u5206\u3002<\/p>\n<p>\u5b83\u4e0d\u662f\u7b80\u5355\u5730\u63a8\u5bfc\u8868\u8fbe\u5f0f\u7684\u503c\u7c7b\u578b&#xff0c;\u800c\u662f\u4f1a\u8003\u8651\u8868\u8fbe\u5f0f\u7684\u503c\u7c7b\u522b\u3002<\/p>\n<p>\u4e3b\u8981\u5206\u4e3a\u4e09\u79cd\u60c5\u51b5&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\n<p>\u8868\u8fbe\u5f0f\u7c7b\u578b<\/p>\n<p>decltype \u63a8\u5bfc\u7ed3\u679c<\/p>\n<\/tr>\n<tr>\n<td>\n<p>\u666e\u901a\u53d8\u91cf\u540d&#xff08;\u4e0d\u52a0\u62ec\u53f7&#xff09;<\/p>\n<\/td>\n<td>\n<p>\u8be5\u53d8\u91cf\u58f0\u660e\u65f6\u7684\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5de6\u503c\u8868\u8fbe\u5f0f<\/p>\n<\/td>\n<td>\n<p>T&amp;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u5c06\u4ea1\u503c\u8868\u8fbe\u5f0f<\/p>\n<\/td>\n<td>\n<p>T&amp;&amp;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u7eaf\u53f3\u503c\u8868\u8fbe\u5f0f<\/p>\n<\/td>\n<td>\n<p>T<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6211\u4eec\u9010\u4e2a\u7406\u89e3\u3002<\/p>\n<h4>1. \u666e\u901a\u53d8\u91cf\u540d&#xff1a;\u63a8\u5bfc\u53d8\u91cf\u58f0\u660e\u65f6\u7684\u7c7b\u578b<\/h4>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a) x &#061; 20;<\/p>\n<p>x \u7684\u7c7b\u578b\u662f int\u3002<\/p>\n<p>\u7279\u522b\u6ce8\u610f&#xff1a;<\/p>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a) x &#061; 20;<\/p>\n<p>\u8fd9\u91cc&#xff1a;<\/p>\n<ul>\n<li>\n<p>decltype(a) \u662f int\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5f53\u8868\u8fbe\u5f0f\u662f\u672a\u52a0\u62ec\u53f7\u7684\u6807\u8bc6\u7b26\u8868\u8fbe\u5f0f\u65f6&#xff0c;\u76f4\u63a5\u4f7f\u7528\u8be5\u6807\u8bc6\u7b26\u6240\u58f0\u660e\u7684\u7c7b\u578b\u3002<\/p>\n<h4>2. \u5de6\u503c\u8868\u8fbe\u5f0f&#xff1a;\u63a8\u5bfc\u4e3a T&amp;<\/h4>\n<p>int a &#061; 10;<\/p>\n<p>decltype((a)) b &#061; a;<\/p>\n<p>\u63a8\u5bfc\u7ed3\u679c&#xff1a;<\/p>\n<p>int&amp; b &#061; a;<\/p>\n<p>\u56e0\u4e3a (a) \u662f\u5de6\u503c\u8868\u8fbe\u5f0f\u3002<\/p>\n<h4>3. \u5c06\u4ea1\u503c\u8868\u8fbe\u5f0f&#xff1a;\u63a8\u5bfc\u4e3a T&amp;&amp;<\/h4>\n<p>int a &#061; 10;<\/p>\n<p>decltype(std::move(a)) b &#061; std::move(a);<\/p>\n<p>\u63a8\u5bfc\u7ed3\u679c&#xff1a;<\/p>\n<p>int&amp;&amp; b &#061; std::move(a);<\/p>\n<p>\u56e0\u4e3a std::move(a) \u662f\u5c06\u4ea1\u503c\u8868\u8fbe\u5f0f&#xff08;xvalue&#xff09;\u3002<\/p>\n<h4>4. \u7eaf\u53f3\u503c\u8868\u8fbe\u5f0f&#xff1a;\u63a8\u5bfc\u4e3a T<\/h4>\n<p>decltype(10) a &#061; 10;<\/p>\n<p>\u63a8\u5bfc\u7ed3\u679c&#xff1a;<\/p>\n<p>int a &#061; 10;<\/p>\n<p>\u56e0\u4e3a\u5b57\u9762\u91cf 10 \u662f\u7eaf\u53f3\u503c&#xff08;prvalue&#xff09;\u3002<\/p>\n<h3>\u56db\u3001\u51e0\u4e2a\u7279\u522b\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9<\/h3>\n<h4>\u6ce8\u610f\u4e8b\u9879 1&#xff1a;decltype(a) \u548c decltype((a)) \u4e0d\u4e00\u6837&#xff0c;\u8fd9\u4e2a\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e5f\u5df2\u7ecf\u8bf4\u660e&#xff0c;\u8fd9\u91cc\u867d\u7136\u6709\u70b9\u91cd\u590d&#xff0c;\u4f46\u662f\u4e5f\u518d\u6b21\u8bf4\u660e\u4e00\u4e0b\u5427<\/h4>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a) x &#061; 20;     \/\/ int<br \/>\ndecltype((a)) y &#061; a;    \/\/ int&amp;<\/p>\n<p>\u8bb0\u5fc6\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e0d\u52a0\u62ec\u53f7\u7684\u53d8\u91cf\u540d&#xff1a;\u53d6\u53d8\u91cf\u58f0\u660e\u7c7b\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>\u52a0\u62ec\u53f7\u540e&#xff1a;\u6309\u7167\u8868\u8fbe\u5f0f\u7684\u503c\u7c7b\u522b\u63a8\u5bfc\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>\u6ce8\u610f\u4e8b\u9879 2&#xff1a;const \u548c\u5f15\u7528\u5c5e\u6027\u4f1a\u4fdd\u7559<\/h4>\n<p>const int a &#061; 10;<\/p>\n<p>decltype(a) b &#061; 20;<\/p>\n<p>\u6b64\u65f6&#xff1a;<\/p>\n<p>const int b &#061; 20;<\/p>\n<p>\u56e0\u4e3a decltype(a) \u4f1a\u4fdd\u7559\u539f\u53d8\u91cf\u7684 const \u5c5e\u6027\u3002<\/p>\n<p>\u518d\u770b&#xff1a;<\/p>\n<p>int x &#061; 10;<br \/>\nint&amp; ref &#061; x;<\/p>\n<p>decltype(ref) another &#061; x;<\/p>\n<p>another \u4ecd\u7136\u662f int&amp;&#xff0c;\u800c\u4e0d\u662f int\u3002<\/p>\n<h4>\u6ce8\u610f\u4e8b\u9879 3&#xff1a;decltype \u4e0d\u4f1a\u6267\u884c\u8868\u8fbe\u5f0f<\/h4>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a &#043; 100) b &#061; 20;<\/p>\n<p>\u8fd9\u91cc\u4e0d\u4f1a\u771f\u7684\u6267\u884c a &#043; 100 \u6765\u83b7\u53d6\u7ed3\u679c\u3002<\/p>\n<p>\u7f16\u8bd1\u5668\u53ea\u6839\u636e\u8868\u8fbe\u5f0f\u89c4\u5219\u63a8\u5bfc\u7c7b\u578b\u3002<\/p>\n<h4>\u6ce8\u610f\u4e8b\u9879 4&#xff1a;decltype(auto) \u548c auto \u4e0d\u4e00\u6837<\/h4>\n<p>C&#043;&#043;14 \u5f15\u5165\u4e86 decltype(auto)\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>int a &#061; 10;<\/p>\n<p>auto x &#061; a;<br \/>\ndecltype(auto) y &#061; (a);<\/p>\n<p>\u7ed3\u679c&#xff1a;<\/p>\n<p>int x &#061; 10;<br \/>\nint&amp; y &#061; a;<\/p>\n<p>\u539f\u56e0&#xff1a;<\/p>\n<ul>\n<li>\n<p>auto \u901a\u5e38\u4f1a\u8fdb\u884c\u7c7b\u578b\u63a8\u5bfc&#xff0c;\u5e76\u53bb\u6389\u9876\u5c42 const \u548c\u5f15\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>decltype(auto) \u5219\u5b8c\u5168\u91c7\u7528 decltype \u7684\u63a8\u5bfc\u89c4\u5219\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u56e0\u6b64&#xff0c;decltype(auto) \u53ef\u4ee5\u4fdd\u7559\u5f15\u7528\u548c const \u5c5e\u6027&#xff0c;\u4f46\u4e5f\u5bb9\u6613\u610f\u5916\u8fd4\u56de\u5f15\u7528\u3002<\/p>\n<h3>\u4e94\u3001\u5b9e\u9645\u5f00\u53d1\u4e2d\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528 decltype&#xff1f;<\/h3>\n<table>\n<tbody>\n<tr>\n<p>\u4f7f\u7528\u573a\u666f<\/p>\n<p>\u76ee\u7684<\/p>\n<\/tr>\n<tr>\n<td>\n<p>\u590d\u6742\u53d8\u91cf\u7c7b\u578b<\/p>\n<\/td>\n<td>\n<p>\u907f\u514d\u91cd\u590d\u4e66\u5199\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u6a21\u677f\u7f16\u7a0b<\/p>\n<\/td>\n<td>\n<p>\u6839\u636e\u8868\u8fbe\u5f0f\u63a8\u5bfc\u7ed3\u679c\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u51fd\u6570\u8fd4\u56de\u503c<\/p>\n<\/td>\n<td>\n<p>\u7cbe\u786e\u6307\u5b9a\u8fd4\u56de\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u6cdb\u578b\u4ee3\u7801<\/p>\n<\/td>\n<td>\n<p>\u4fdd\u7559\u8868\u8fbe\u5f0f\u7684\u5f15\u7528\u5c5e\u6027<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>decltype(auto)<\/p>\n<\/td>\n<td>\n<p>\u7cbe\u786e\u4fdd\u7559\u7c7b\u578b\u3001\u5f15\u7528\u548c const \u5c5e\u6027<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u516d\u3001\u6700\u540e\u603b\u7ed3&#xff1a;\u8bb0\u4f4f\u8fd9\u51e0\u4e2a\u6838\u5fc3\u77e5\u8bc6\u70b9<\/h3>\n<p>1. decltype \u7684\u4f5c\u7528<\/p>\n<p>\u6839\u636e\u8868\u8fbe\u5f0f\u63a8\u5bfc\u7c7b\u578b&#xff0c;\u4e0d\u6267\u884c\u8868\u8fbe\u5f0f\u3002<\/p>\n<p>2. \u6700\u91cd\u8981\u7684\u63a8\u5bfc\u89c4\u5219<\/p>\n<p>int a &#061; 10;<\/p>\n<p>decltype(a)    x &#061; 10; \/\/ int<br \/>\ndecltype((a))  y &#061; a;  \/\/ int&amp;<br \/>\ndecltype(10)   z &#061; 10; \/\/ int<\/p>\n<p>3. \u4e09\u79cd\u503c\u7c7b\u522b<\/p>\n<ul>\n<li>\n<p>\u5de6\u503c&#xff08;lvalue&#xff09;&#xff1a;T&amp;<\/p>\n<\/li>\n<li>\n<p>\u5c06\u4ea1\u503c&#xff08;xvalue&#xff09;&#xff1a;T&amp;&amp;<\/p>\n<\/li>\n<li>\n<p>\u7eaf\u53f3\u503c&#xff08;prvalue&#xff09;&#xff1a;T<\/p>\n<\/li>\n<\/ul>\n<p>4. decltype(auto)<\/p>\n<p>\u5b8c\u5168\u6309\u7167 decltype \u89c4\u5219\u63a8\u5bfc&#xff0c;\u80fd\u591f\u4fdd\u7559\u5f15\u7528\u548c const \u5c5e\u6027\u3002<\/p>\n<p>decltype \u4e0d\u53ea\u662f\u63a8\u5bfc\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b&#xff0c;\u8fd8\u80fd\u901a\u8fc7\u8868\u8fbe\u5f0f\u7684\u503c\u7c7b\u522b&#xff0c;\u51c6\u786e\u4fdd\u7559\u5de6\u503c\u5f15\u7528\u3001\u53f3\u503c\u5f15\u7528\u548c const \u5c5e\u6027\u3002<\/p>\n<p>\u8fd9\u4e5f\u662f\u5b83\u5728 C&#043;&#043; \u6a21\u677f\u7f16\u7a0b\u548c\u6cdb\u578b\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u539f\u56e0&#xff0c;\u800c\u4e0d\u662f\u50cf\u6587\u7ae0\u5f00\u5934\u90a3\u91cc\u611f\u89c9\u5927\u8d39\u5468\u7ae0\u53ea\u66ff\u6362\u4e86int<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001decltype \u662f\u4ec0\u4e48&#xff1f;decltype \u662f C11 \u5f15\u5165\u7684\u7c7b\u578b\u63a8\u5bfc\u5173\u952e\u5b57\u3002\u5b83\u7684\u4f5c\u7528\u662f&#xff1a;\u6839\u636e\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u63a8\u5bfc\u51fa\u8be5\u8868\u8fbe\u5f0f\u5bf9\u5e94\u7684\u7c7b\u578b&#xff0c;\u5e76\u5c06\u5176\u4f5c\u4e3a\u53d8\u91cf\u3001\u51fd\u6570\u8fd4\u56de\u503c\u6216\u5176\u4ed6\u58f0\u660e\u7684\u7c7b\u578b\u3002\u57fa\u672c\u8bed\u6cd5&#xff1a;decltype(expression) variable;\u4f8b\u5982&#xff1a;int a  10;decltype(a) b  20;\u6b64\u65f6 decltype(a) \u63a8\u5bfc\u51fa int&#xff0c;\u56e0\u6b64\u76f8\u5f53\u4e8e&amp;#xff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,190],"topic":[],"class_list":["post-120467","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/120467.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001decltype \u662f\u4ec0\u4e48&#xff1f;decltype \u662f C11 \u5f15\u5165\u7684\u7c7b\u578b\u63a8\u5bfc\u5173\u952e\u5b57\u3002\u5b83\u7684\u4f5c\u7528\u662f&#xff1a;\u6839\u636e\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u63a8\u5bfc\u51fa\u8be5\u8868\u8fbe\u5f0f\u5bf9\u5e94\u7684\u7c7b\u578b&#xff0c;\u5e76\u5c06\u5176\u4f5c\u4e3a\u53d8\u91cf\u3001\u51fd\u6570\u8fd4\u56de\u503c\u6216\u5176\u4ed6\u58f0\u660e\u7684\u7c7b\u578b\u3002\u57fa\u672c\u8bed\u6cd5&#xff1a;decltype(expression) variable;\u4f8b\u5982&#xff1a;int a 10;decltype(a) b 20;\u6b64\u65f6 decltype(a) \u63a8\u5bfc\u51fa int&#xff0c;\u56e0\u6b64\u76f8\u5f53\u4e8e&amp;#xff1a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/120467.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-31T11:24:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120467.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/120467.html\",\"name\":\"c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-31T11:24:29+00:00\",\"dateModified\":\"2026-10-31T11:24:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/120467.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/120467.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120467.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"c++\u7684decltype\u662f\u4ec0\u4e48\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/120467.html","og_locale":"zh_CN","og_type":"article","og_title":"c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001decltype \u662f\u4ec0\u4e48&#xff1f;decltype \u662f C11 \u5f15\u5165\u7684\u7c7b\u578b\u63a8\u5bfc\u5173\u952e\u5b57\u3002\u5b83\u7684\u4f5c\u7528\u662f&#xff1a;\u6839\u636e\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u63a8\u5bfc\u51fa\u8be5\u8868\u8fbe\u5f0f\u5bf9\u5e94\u7684\u7c7b\u578b&#xff0c;\u5e76\u5c06\u5176\u4f5c\u4e3a\u53d8\u91cf\u3001\u51fd\u6570\u8fd4\u56de\u503c\u6216\u5176\u4ed6\u58f0\u660e\u7684\u7c7b\u578b\u3002\u57fa\u672c\u8bed\u6cd5&#xff1a;decltype(expression) variable;\u4f8b\u5982&#xff1a;int a 10;decltype(a) b 20;\u6b64\u65f6 decltype(a) \u63a8\u5bfc\u51fa int&#xff0c;\u56e0\u6b64\u76f8\u5f53\u4e8e&amp;#xff1a","og_url":"https:\/\/www.wsisp.com\/helps\/120467.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-31T11:24:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/120467.html","url":"https:\/\/www.wsisp.com\/helps\/120467.html","name":"c++\u7684decltype\u662f\u4ec0\u4e48 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-31T11:24:29+00:00","dateModified":"2026-10-31T11:24:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/120467.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/120467.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/120467.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"c++\u7684decltype\u662f\u4ec0\u4e48"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=120467"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120467\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=120467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=120467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=120467"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=120467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}