{"id":3884,"date":"2021-04-29T20:38:12","date_gmt":"2021-04-29T12:38:12","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=3884"},"modified":"2021-04-29T20:55:53","modified_gmt":"2021-04-29T12:55:53","slug":"c%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=3884","title":{"rendered":"[c++]\u5b57\u7b26\u4e32"},"content":{"rendered":"\n<p>\u539f\u59cb\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u4ee5R&#8221;( \u5f00\u5934\uff0c\u4ee5 )&#8221; \u7ed3\u5c3e<br>const char* str = R&#8221;( Hello &#8220;World&#8221;)&#8221;;<\/p>\n\n\n\n<p>\u4f8b\u5982const char* p1= &#8220;Line1\\nLine2&#8221;;<br>\u53ef\u4ee5\u7b49\u4ef7\u4e3a<br>const char* p1 = R&#8221;(Line1<br>Line2)&#8221;;<\/p>\n\n\n\n<p>\u9ed8\u8ba4\u4e3a(\u548c)\u4e3a\u5b57\u9762\u91cf\u8bed\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u6269\u5c55\u539f\u59cb\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u8bed\u6cd5<br>R&#8221;X( &#8230;. )X&#8221;<\/p>\n\n\n\n<p>\u4f8b\u5982<\/p>\n\n\n\n<p>const char* str = R&#8221;-(Embedded )&#8221; characters)-&#8220;;<\/p>\n\n\n\n<p>\/\/ std::to_string \u63d0\u4f9b\u4e86\u6570\u503c\u5411\u5b57\u7b26\u4e32\u8f6c\u6362\u7684\u5185\u5efa\u51fd\u6570<br>auto s = std::to_string(102);<\/p>\n\n\n\n<p>\/\/ \u8fd8\u6709<br>std::atoi, stoi, stol, stod &#8230;<\/p>\n\n\n\n<p>\/\/ \u53ef\u4ee5\u4f7f\u7528to_chars\u8fdb\u884c\u4e00\u4e9b\u4f4e\u7ea7\u6570\u503c\u8f6c\u6362<br>std::to_chars(&#8230;<br>std::from_chars(&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">std::string_view\u7c7b<\/h2>\n\n\n\n<p>\u5728C++17\u4e4b\u524d\uff0c\u6df7\u7528const char* \u548c std::string\u662f\u975e\u5e38\u75db\u82e6\u7684\uff0c\u6216\u8005\u6dfb\u52a0const std::string&amp;\uff0c\u5e76\u4e0d\u4f18\u96c5<\/p>\n\n\n\n<p>C++17\u5f15\u7528\u4e86std::string_view\u7c7b\uff0c\u5b83\u4e0d\u590d\u5236\u5b57\u7b26\u4e32\uff0c\u652f\u6301\u4e0estd::string\u7c7b\u4f3c\u7684\u63a5\u53e3\uff0c\u7f3a\u5c11c_str()\u4f46\u662f\u652f\u6301data();<\/p>\n\n\n\n<p>using namespace std::string_view_literals;<br>\u6216\u8005 using namespace std;<br>auto sv = &#8220;hello world&#8221;sv;<\/p>\n\n\n\n<p>\u6b64\u7279\u6027\u9700\u8981\u652f\u6301C++17\u7279\u6027<br>VS2019\u9ed8\u8ba4\u6ca1\u6709\u6253\u5f00C++17\uff0c\u9700\u8981\u624b\u5de5\u6253\u5f00<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"547\" src=\"http:\/\/blog.coolcoding.cn\/wp-content\/uploads\/2021\/04\/image.png\" alt=\"\" class=\"wp-image-3891\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u59cb\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u4ee5R&#8221;( \u5f00\u5934\uff0c\u4ee5 )&#8221; \u7ed3\u5c3econst char* str = R&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/3884"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3884"}],"version-history":[{"count":7,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/3884\/revisions"}],"predecessor-version":[{"id":3892,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/3884\/revisions\/3892"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}