프로그래밍 검색 블로그

C++ ranges action::join 본문

C++ ranges

C++ ranges action::join

코딩조무사 2017. 10. 15. 16:37

원본 자체는 변경이 불가능하고 복사 혹은 이동만 가능하다 



1
2
3
4
vector<vector<int> > v = {
    {12345},
    {67890}
};
cs



복사

1
2
3
     auto flatCopy = v | ranges::copy | action::join;
    
    cout << view::all(flatMove) << endl;
cs



이동
1
2
3
    auto flatMove = v | ranges::move | action::join;
   
    cout << view::all(flatMove) << endl;
cs










문자열도 가능 

1
2
3
4
5
    vector<std::string> strs = {"show","me","the","money"};
    
    std::string flatCopy = strs | ranges::copy | action::join;
    
    cout << view::all(flatCopy) << endl;
cs


'C++ ranges' 카테고리의 다른 글

C++ ranges view::zip  (0) 2017.10.16
C++ ranges accumulate  (0) 2017.10.15
C++ ranges action::unique  (0) 2017.10.15
C++ ranges action::sort  (0) 2017.10.15
C++ ranges action::take  (0) 2017.10.10
Comments