久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <small id='ObavJ'></small><noframes id='ObavJ'>

      1. <i id='ObavJ'><tr id='ObavJ'><dt id='ObavJ'><q id='ObavJ'><span id='ObavJ'><b id='ObavJ'><form id='ObavJ'><ins id='ObavJ'></ins><ul id='ObavJ'></ul><sub id='ObavJ'></sub></form><legend id='ObavJ'></legend><bdo id='ObavJ'><pre id='ObavJ'><center id='ObavJ'></center></pre></bdo></b><th id='ObavJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ObavJ'><tfoot id='ObavJ'></tfoot><dl id='ObavJ'><fieldset id='ObavJ'></fieldset></dl></div>
      2. <legend id='ObavJ'><style id='ObavJ'><dir id='ObavJ'><q id='ObavJ'></q></dir></style></legend>

          <bdo id='ObavJ'></bdo><ul id='ObavJ'></ul>
        <tfoot id='ObavJ'></tfoot>
      3. 遞歸地傳遞一個字符串而不需要娛樂

        Pass a string Recursively without Recreation(遞歸地傳遞一個字符串而不需要娛樂)

          <tbody id='S9g3s'></tbody>
        1. <tfoot id='S9g3s'></tfoot>
            <legend id='S9g3s'><style id='S9g3s'><dir id='S9g3s'><q id='S9g3s'></q></dir></style></legend>

                <bdo id='S9g3s'></bdo><ul id='S9g3s'></ul>

                <small id='S9g3s'></small><noframes id='S9g3s'>

                <i id='S9g3s'><tr id='S9g3s'><dt id='S9g3s'><q id='S9g3s'><span id='S9g3s'><b id='S9g3s'><form id='S9g3s'><ins id='S9g3s'></ins><ul id='S9g3s'></ul><sub id='S9g3s'></sub></form><legend id='S9g3s'></legend><bdo id='S9g3s'><pre id='S9g3s'><center id='S9g3s'></center></pre></bdo></b><th id='S9g3s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='S9g3s'><tfoot id='S9g3s'></tfoot><dl id='S9g3s'><fieldset id='S9g3s'></fieldset></dl></div>

                  本文介紹了遞歸地傳遞一個字符串而不需要娛樂的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我在這里回答了一個問題:https://stackoverflow.com/a/28862668/2642059我需要在哪里使用重復(fù)來遍歷 string.我想在每個函數(shù)上使用 const string& 作為我的參數(shù),但是除非我想在每次遞歸時重建字符串,否則我發(fā)現(xiàn)我需要傳遞一個 startfinish 位置以及 string 本身.所以傳遞 string 變得毫無意義.

                  I answered a question here: https://stackoverflow.com/a/28862668/2642059 Where I needed to use recurrence to step through a string. I wanted to use a const string& as my parameter on each function, but unless I wanted to reconstruct the string each recursion I found that I needed to pass a start and finish position as well as the string itself. So it became pointless to pass the string at all.

                  最后我選擇只將 startfinish 指針傳遞給 char[].

                  In the end I choose to just pass a start and finish pointer to the char[].

                  舉個例子,假設(shè)我得到一個包含嵌套括號的字符串(但沒有并排插入括號.)就像這樣:

                  As an example, say that I'm given a string which contains nested parenthesis (but no side by side parenthetical insertions.) So like this:

                  (abc(def(ghi((j)klm)nop)qrs)tuv)wxyz

                  (abc(def(ghi((j)klm)nop)qrs)tuv)wxyz

                  但不是這樣:

                  (abc(def)(ghi)(j)(klm)(nop)(qrs)tuv)wxyz

                  (abc(def)(ghi)(j)(klm)(nop)(qrs)tuv)wxyz

                  我想編寫一個遞歸程序來提取最深嵌套括號中的字符串.類似的東西:

                  I want to write a recursive program to extract the string in the deepest nested parentheses. Something like:

                  string foo(const string& bar){
                      auto start = bar.find('(') + 1;
                  
                      return start == string::npos + 1 ? bar : foo(bar.substr(start, bar.find_last_of(')') - start));
                  }
                  

                  然而,我不高興為 foo 的每次重復(fù)重建一個 string.另一種方法是像鏈接示例中一樣傳遞 startfinish 指針(或傳遞 string::const_iterators.)

                  However I'm unhappy reconstructing a string for each recurrence of foo. The alternative is to pass start and finish pointers as in the linked example (or to pass string::const_iterators.)

                  是否有包裝器或其他東西可以讓我使用 string 功能,但不能重建 string?

                  Is there a wrapper or something which would allow me to use string functionality, but not reconstruct a string?

                  推薦答案

                  string_view 來自庫基礎(chǔ)知識 TS 可能是一個想法,在 GCC 中提供支持.

                  string_view from the library fundamentals TS might be one idea, support is available in GCC.

                  接口實際上與string

                  #include <experimental/string_view>
                  using std::experimental::string_view;
                  
                  string_view foo(const string_view& bar){
                      auto start = bar.find('(') + 1;
                  
                      return start == string_view::npos + 1 ? bar : foo(bar.substr(start, bar.find_last_of(')') - start));
                  }
                  

                  最后一行也可以

                  return start ? foo(bar.substr(start, bar.find_last_of(')') - start)) : bar;
                  

                  雖然它們都很神秘.

                  這篇關(guān)于遞歸地傳遞一個字符串而不需要娛樂的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)

                  <small id='y6LL7'></small><noframes id='y6LL7'>

                          <bdo id='y6LL7'></bdo><ul id='y6LL7'></ul>
                            <tbody id='y6LL7'></tbody>

                            <i id='y6LL7'><tr id='y6LL7'><dt id='y6LL7'><q id='y6LL7'><span id='y6LL7'><b id='y6LL7'><form id='y6LL7'><ins id='y6LL7'></ins><ul id='y6LL7'></ul><sub id='y6LL7'></sub></form><legend id='y6LL7'></legend><bdo id='y6LL7'><pre id='y6LL7'><center id='y6LL7'></center></pre></bdo></b><th id='y6LL7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='y6LL7'><tfoot id='y6LL7'></tfoot><dl id='y6LL7'><fieldset id='y6LL7'></fieldset></dl></div>
                          • <legend id='y6LL7'><style id='y6LL7'><dir id='y6LL7'><q id='y6LL7'></q></dir></style></legend>

                          • <tfoot id='y6LL7'></tfoot>
                            主站蜘蛛池模板: 亚洲欧美中文字幕在线观看 | 久久精品国产精品青草 | 亚洲 精品 综合 精品 自拍 | 午夜激情一区 | 91精品国产91久久久久久最新 | 性生生活大片免费看视频 | 国产免费一区 | 久久精品av麻豆的观看方式 | 特黄特黄a级毛片免费专区 av网站免费在线观看 | 欧美日本韩国一区二区三区 | 在线观看a视频 | 色网在线播放 | 精品av天堂毛片久久久借种 | 91精品久久久久久久久久入口 | 日韩av在线中文字幕 | 成人一区二区三区在线观看 | 精品中文字幕在线 | 青春草在线 | 91久久伊人 | 久久久久国产一区二区三区 | 午夜影院在线观看 | 国产人成精品一区二区三 | 99国内精品久久久久久久 | 亚洲激情一区二区三区 | 最新国产精品视频 | 亚洲另类视频 | 中文字幕在线观看一区 | 日韩av在线一区 | 免费一级黄色 | 国产精品久久久久久久久久免费看 | 久久不卡 | 99re视频在线 | 亚洲精品九九 | 99精品国产一区二区青青牛奶 | 夜夜艹天天干 | h视频在线观看免费 | av 一区二区三区 | 天天综合91| 中文字幕日韩欧美一区二区三区 | 欧美精品一| 亚洲成人免费观看 |