Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- traits
- program
- WebView
- stringprintf
- template
- web
- Android
- sprintf
- SHA512
- Chrono
- Observer
- CustomTab
- Reflect
- design pattern
- SHA1
- haskell
- kotlin
- sha256
- go
- c++
- Clojure
- async
- ranges
- ChromeTab
- type_traits
- RAII
- AES
- Scala
- Functional
- coroutines
Archives
- Today
- Total
프로그래밍 검색 블로그
C++ ranges view::replace, view::replace_if 본문
replace
첫번쨰로 들어온 원소와 같은게 있다면 두번째로 들어온 원소로 바꾼다.
1 2 3 | vector<int> v = view::iota(0, 10) | view::replace(6,10); cout << view::all(v) << endl; | cs |
출력: [0,1,2,3,4,5,10,7,8,9]
replace_if
인자로 받은 함수에 원소를 넣어서 같다면 두번쨰 인자로 바꾼다.
1 2 3 4 5 | vector<int> v = view::iota(0, 10) | view::replace_if([](int e){ return e == 6; }, 10); cout << view::all(v) << endl; | cs |
출력: [0,1,2,3,4,5,10,7,8,9]
'C++ ranges' 카테고리의 다른 글
C++ ranges view::keys, view::values (0) | 2017.10.08 |
---|---|
C++ ranges view::ints (0) | 2017.10.08 |
c++ ranges view:transform (0) | 2017.10.08 |
C++ ranges view::drop, view::drop_while, view::drop_exactly (0) | 2017.10.08 |
C++ ranges view::group_by (0) | 2017.10.08 |
Comments