{"id":102,"date":"2021-05-26T13:25:31","date_gmt":"2021-05-26T05:25:31","guid":{"rendered":"https:\/\/blog.cauchyschwarz.com\/?p=102"},"modified":"2021-05-27T22:45:43","modified_gmt":"2021-05-27T14:45:43","slug":"c-inline%e5%85%b3%e9%94%ae%e5%ad%97","status":"publish","type":"post","link":"https:\/\/blog.cauchyschwarz.com\/?p=102","title":{"rendered":"C++ inline\u5173\u952e\u5b57"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u6307\u5b9a\u51fd\u6570\u4e3ainline<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u51fd\u6570\u7684\u5b9a\u4e49\u5904\u52a0\u4e0ainline\u5173\u952e\u5b57\uff0c\u51fd\u6570\u58f0\u660e\u7684\u5730\u65b9\u4e0d\u9700\u8981\u52a0inline\u58f0\u660e\u3002\u5e76\u4e14\u51fd\u6570\u7684\u5b9a\u4e49\u4e5f\u5fc5\u987b\u653e\u5728\u5934\u6587\u4ef6\u91cc(\u9664\u975e\u8fd9\u4e2a\u51fd\u6570\u5b9a\u4e49\u4e5f\u653e\u5728\u8c03\u7528\u7684\u90a3\u4e2acpp\u6587\u4ef6\u91cc)\uff0c\u5426\u5219\u7f16\u8bd1\u5668\u4e0d\u4f1a\u5185\u8054\u4ee3\u7801\uff0c\u8fd8\u662f\u6309\u7167\u666e\u901a\u51fd\u6570\u8c03\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u7c7b\u6210\u5458\u51fd\u6570\u7684\u5b9a\u4e49\u5c31\u5728\u7c7b\u7684\u5b9a\u4e49\u7684\u4ee3\u7801\u5757\u91cc\uff0c\u90a3\u4e48\u8fd9\u4e2a\u6210\u5458\u51fd\u6570\u662f\u81ea\u52a8\u5b9e\u73b0\u4e3ainline\u51fd\u6570\uff0c\u6b64\u65f6\u4e0d\u9700\u8981inline\u5173\u952e\u5b57\u3002\u5982\u679c\u7c7b\u6210\u5458\u51fd\u6570\u7684\u5b9a\u4e49\u548c\u58f0\u660e\u5206\u5f00\u4e86\uff0c\u90a3\u4e48\u9700\u8981\u5728\u5b9a\u4e49\u7684\u5730\u65b9\u52a0\u4e0ainline\u5173\u952e\u5b57\uff0c\u800c\u4e14\u5b9a\u4e49\u4e5f\u5fc5\u987b\u653e\u5728\u5934\u6587\u4ef6\u91cc(\u9664\u975e\u8fd9\u4e2a\u6210\u5458\u51fd\u6570\u5b9a\u4e49\u4e5f\u653e\u5728\u8c03\u7528\u7684\u90a3\u4e2acpp\u6587\u4ef6\u91cc)\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Fred {\npublic:\n  void f(int i, char c)\n    {\n      \/\/ ...\n    }\n};<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5373\u4f7f\u6307\u5b9a\u4e86inline\u5173\u952e\u5b57\uff0c\u7f16\u8bd1\u5668\u4e5f\u4e0d\u4e00\u5b9a\u5b9e\u73b0\u4e3a\u5185\u8054\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">inline\u4e0d\u4e00\u5b9a\u6709\u901f\u5ea6\u3001\u4ee3\u7801\u5927\u5c0f\u4e4b\u7c7b\u7684\u9884\u671f\u6548\u679c\uff0c\u8981\u770b\u5177\u4f53\u5e94\u7528\u573a\u666f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/isocpp.org\/wiki\/faq\/inline-functions\">https:\/\/isocpp.org\/wiki\/faq\/inline-functions<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">inline\u4e0d\u80fd\u6210\u529f\u7684\u60c5\u5f62\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Note that certain usages in a function definition can make it unsuitable for inline substitution. Among these usages are: variadic functions, use of\u00a0<code>alloca<\/code>, use of computed goto (see\u00a0<a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Labels-as-Values.html#Labels-as-Values\">Labels as Values<\/a>), use of nonlocal goto, use of nested functions, use of\u00a0<code>setjmp<\/code>, use of\u00a0<code>__builtin_longjmp<\/code>\u00a0and use of\u00a0<code>__builtin_return<\/code>\u00a0or\u00a0<code>__builtin_apply_args<\/code>.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8bd1\u65f6\u52a0\u4e0a-Winline\u53c2\u6570\uff0c\u5bf9\u6807\u8bb0\u4e86inline\uff0c\u4f46\u662f\u7f16\u8bd1\u5668\u4e0d\u80fd\u5b9e\u73b0\u4e3ainline\u7684\u51fd\u6570\u53d1\u51fa\u544a\u8b66\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Inline.html#Inline\">https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Inline.html#Inline<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6307\u5b9a\u51fd\u6570\u4e3ainline \u5728\u51fd\u6570\u7684\u5b9a\u4e49\u5904\u52a0\u4e0ainline\u5173\u952e\u5b57\uff0c\u51fd\u6570\u58f0\u660e\u7684\u5730\u65b9\u4e0d\u9700\u8981\u52a0inline\u58f0\u660e\u3002\u5e76\u4e14\u51fd\u6570\u7684\u5b9a\u4e49\u4e5f\u5fc5\u987b\u653e\u5728\u5934\u6587\u4ef6\u91cc(\u9664\u975e\u8fd9\u4e2a\u51fd\u6570\u5b9a\u4e49\u4e5f\u653e\u5728\u8c03\u7528\u7684\u90a3\u4e2acpp\u6587\u4ef6\u91cc)\uff0c\u5426\u5219\u7f16\u8bd1\u5668\u4e0d\u4f1a\u5185&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[8],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-10","tag-c"],"_links":{"self":[{"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":2,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cauchyschwarz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}