{"id":106616,"date":"2026-09-17T19:56:35","date_gmt":"2026-09-17T11:56:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106616.html"},"modified":"2026-09-17T19:56:35","modified_gmt":"2026-09-17T11:56:35","slug":"c-lambda%e8%a1%a8%e8%be%be%e5%bc%8f%e6%b7%b1%e5%85%a5%e5%85%a8%e8%a7%a3%e6%9e%90%ef%bc%8c%e9%9d%a2%e8%af%95%e5%bf%85%e8%80%83%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106616.html","title":{"rendered":"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01"},"content":{"rendered":"<h2>C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01<\/h2>\n<p>Lambda\u662fC++11\u5f15\u5165\u7684\u533f\u540d\u51fd\u6570\u7279\u6027\uff0c\u73b0\u4ee3C++\u7f16\u7a0b\u5fc5\u5907\u6280\u80fd\u3002\u672c\u6587\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\uff0c\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1Lambda\u3002<\/p>\n<h3>\u4e00\u3001Lambda\u57fa\u7840\u8bed\u6cd5<\/h3>\n<h4>1.1 \u57fa\u672c\u5f62\u5f0f<\/h4>\n<p><span class=\"token comment\">\/\/ \u5b8c\u6574\u8bed\u6cd5<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>capture<span class=\"token operator\">&#8211;<\/span>list<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">(<\/span>parameters<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">mutable<\/span> <span class=\"token operator\">-&gt;<\/span> <span class=\"token keyword\">return<\/span><span class=\"token operator\">&#8211;<\/span>type <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> body <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6700\u7b80\u5f62\u5f0f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5b9e\u9645\u4f7f\u7528<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> add <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">-&gt;<\/span> <span class=\"token keyword\">int<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">+<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u8f93\u51fa: 7<\/span><\/p>\n<h4>1.2 \u5404\u90e8\u5206\u8be6\u89e3<\/h4>\n<p><span class=\"token comment\">\/\/ 1. \u6355\u83b7\u5217\u8868 [capture-list]<\/span><br \/>\n<span class=\"token comment\">\/\/ 2. \u53c2\u6570\u5217\u8868 (parameters) &#8211; \u53ef\u9009<\/span><br \/>\n<span class=\"token comment\">\/\/ 3. mutable &#8211; \u53ef\u9009\uff0c\u5141\u8bb8\u4fee\u6539\u6309\u503c\u6355\u83b7\u7684\u53d8\u91cf<\/span><br \/>\n<span class=\"token comment\">\/\/ 4. \u8fd4\u56de\u7c7b\u578b -&gt; return-type &#8211; \u53ef\u9009\uff0c\u53ef\u81ea\u52a8\u63a8\u5bfc<\/span><br \/>\n<span class=\"token comment\">\/\/ 5. \u51fd\u6570\u4f53 { body }<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u7701\u7565\u8fd4\u56de\u7c7b\u578b\uff08\u81ea\u52a8\u63a8\u5bfc\uff09<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> add <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">+<\/span> b<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u8fd4\u56de\u7c7b\u578b\u63a8\u5bfc\u4e3aint<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u7701\u7565\u53c2\u6570\u5217\u8868<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> greet <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">\\&#8221;Hello!\\&#8221;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>\u4e8c\u3001\u6355\u83b7\u5217\u8868\u8be6\u89e3<\/h3>\n<h4>2.1 \u6355\u83b7\u65b9\u5f0f<\/h4>\n<p><span class=\"token keyword\">int<\/span> x <span class=\"token operator\">=<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span> y <span class=\"token operator\">=<\/span> <span class=\"token number\">20<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 1. \u7a7a\u6355\u83b7\uff1a\u4e0d\u6355\u83b7\u4efb\u4f55<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f1 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token keyword\">return<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 2. \u6309\u503c\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f2 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span>x<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token keyword\">return<\/span> x<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6355\u83b7x\u7684\u526f\u672c<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 3. \u6309\u5f15\u7528\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f3 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">&amp;<\/span>x<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> x<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">return<\/span> x<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6355\u83b7x\u7684\u5f15\u7528<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 4. \u9690\u5f0f\u6309\u503c\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f4 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">=<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token keyword\">return<\/span> x <span class=\"token operator\">+<\/span> y<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6355\u83b7\u6240\u6709\u4f7f\u7528\u7684\u53d8\u91cf<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 5. \u9690\u5f0f\u6309\u5f15\u7528\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f5 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">&amp;<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> x<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> y<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u6355\u83b7\u6240\u6709\u4f7f\u7528\u7684\u53d8\u91cf<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 6. \u6df7\u5408\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f6 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">=<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>x<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> x<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">return<\/span> y<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u9ed8\u8ba4\u503c\u6355\u83b7\uff0cx\u5f15\u7528\u6355\u83b7<\/span><br \/>\n<span class=\"token keyword\">auto<\/span> f7 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">&amp;<\/span><span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> x<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> y<span class=\"token operator\">++<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u9ed8\u8ba4\u5f15\u7528\u6355\u83b7\uff0cx\u503c\u6355\u83b7<\/span><\/p>\n<h4>2.2 \u6355\u83b7this\u6307\u9488<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Widget<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    <span class=\"token keyword\">int<\/span> value_ <span class=\"token operator\">=<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">public<\/span><span class=\"token operator\">:<\/span><br \/>\n    <span class=\"token keyword\">void<\/span> <span class=\"token function\">doSomething<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n        <span class=\"token comment\">\/\/ \u6355\u83b7this\u6307\u9488<\/span><br \/>\n        <span class=\"token keyword\">auto<\/span> f1 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token keyword\">return<\/span> value_<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">auto<\/span> f2 <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token operator\">*<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> <span class=\"token keyword\">return<\/span> value_<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ C++17\uff1a\u6355\u83b7this\u7684\u526f\u672c<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u5728\u6210\u5458\u51fd\u6570\u4e2d\u4f7f\u7528Lambda<\/span><br \/>\n        std<span class=\"token double-colon punctuation\">::<\/span>vector<span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">&gt;<\/span> vec <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">for_each<\/span><span class=\"token punctuation\">(<\/span>vec<span class=\"token punctuation\">.<\/span><span class=\"token function\">begin<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> vec<span class=\"token punctuation\">.<\/span><span class=\"token function\">end<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 Lambda\u662fC++11\u5f15\u5165\u7684\u533f\u540d\u51fd\u6570\u7279\u6027\uff0c\u73b0\u4ee3C++\u7f16\u7a0b\u5fc5\u5907\u6280\u80fd\u3002\u672c\u6587\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\uff0c\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1Lambda\u3002 \u4e00\u3001Lambda\u57fa\u7840\u8bed\u6cd5<br \/>\n1.1 \u57fa\u672c\u5f62\u5f0f<br \/>\n\/\/ \u5b8c\u6574\u8bed\u6cd5<br \/>\n[capture-list](parameters) mutable -&gt; return-type {body }\/\/ \u6700\u7b80\u5f62\u5f0f<br \/>\n[]() {};\/\/ \u5b9e\u9645\u4f7f\u7528<br \/>\nauto add = [](int a, int b) -&gt; int {return a <\/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,5364,190,176],"topic":[],"class_list":["post-106616","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-lambda","tag-190","tag-176"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \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\/106616.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 Lambda\u662fC++11\u5f15\u5165\u7684\u533f\u540d\u51fd\u6570\u7279\u6027\uff0c\u73b0\u4ee3C++\u7f16\u7a0b\u5fc5\u5907\u6280\u80fd\u3002\u672c\u6587\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\uff0c\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1Lambda\u3002 \u4e00\u3001Lambda\u57fa\u7840\u8bed\u6cd5 1.1 \u57fa\u672c\u5f62\u5f0f \/\/ \u5b8c\u6574\u8bed\u6cd5 [capture-list](parameters) mutable -&gt; return-type {body }\/\/ \u6700\u7b80\u5f62\u5f0f []() {};\/\/ \u5b9e\u9645\u4f7f\u7528 auto add = [](int a, int b) -&gt; int {return a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106616.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-17T11:56:35+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106616.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106616.html\",\"name\":\"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-17T11:56:35+00:00\",\"dateModified\":\"2026-09-17T11:56:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106616.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106616.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106616.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01\"}]},{\"@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++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \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\/106616.html","og_locale":"zh_CN","og_type":"article","og_title":"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 Lambda\u662fC++11\u5f15\u5165\u7684\u533f\u540d\u51fd\u6570\u7279\u6027\uff0c\u73b0\u4ee3C++\u7f16\u7a0b\u5fc5\u5907\u6280\u80fd\u3002\u672c\u6587\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\uff0c\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1Lambda\u3002 \u4e00\u3001Lambda\u57fa\u7840\u8bed\u6cd5 1.1 \u57fa\u672c\u5f62\u5f0f \/\/ \u5b8c\u6574\u8bed\u6cd5 [capture-list](parameters) mutable -&gt; return-type {body }\/\/ \u6700\u7b80\u5f62\u5f0f []() {};\/\/ \u5b9e\u9645\u4f7f\u7528 auto add = [](int a, int b) -&gt; int {return a","og_url":"https:\/\/www.wsisp.com\/helps\/106616.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-17T11:56:35+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106616.html","url":"https:\/\/www.wsisp.com\/helps\/106616.html","name":"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-17T11:56:35+00:00","dateModified":"2026-09-17T11:56:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106616.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106616.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106616.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++ Lambda\u8868\u8fbe\u5f0f\u6df1\u5165\u5168\u89e3\u6790\uff0c\u9762\u8bd5\u5fc5\u8003\uff01"}]},{"@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\/106616","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=106616"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106616\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106616"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}