हम्म ... मैंने सोचा कि मैं regexes समझ गई और मैंने सोचा कि मैं iterators समझा, लेकिन सी ++ 11 की regex कार्यान्वयन मुझे हैरान किया है ...सी ++ 11 regex_token_iterator
एक क्षेत्र मुझे समझ नहीं आता: regex token iterators के बारे में पढ़ना, मैं निम्न नमूना कोड भर में आया था:
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <regex>
int main()
{
std::string text = "Quick brown fox.";
// tokenization (non-matched fragments)
// Note that regex is matched only two times: when the third value is obtained
// the iterator is a suffix iterator.
std::regex ws_re("\\s+"); // whitespace
std::copy(std::sregex_token_iterator(text.begin(), text.end(), ws_re, -1),
std::sregex_token_iterator(),
std::ostream_iterator<std::string>(std::cout, "\n"));
...
}
मुझे समझ नहीं आता कैसे निम्नलिखित उत्पादन:
Quick
brown
fox.
() std :: प्रतिलिपि द्वारा बनाई जा रही है कार्यात्मक ऊपर एन मुझे कोई लूप नहीं दिख रहा है, इसलिए मैं परेशान हूं कि पुनरावृत्ति कैसा चल रहा है। या एक और तरीका रखो, उत्पादन की एक से अधिक पंक्ति कैसे उत्पन्न की जा रही है?
यह प्रत्येक आउटपुट में प्रतिलिपि बनाता है। लूप 'प्रतिलिपि' के अंदर है। – chris