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
- stringprintf
- web
- Observer
- Reflect
- CustomTab
- AES
- design pattern
- SHA1
- sha256
- program
- template
- c++
- RAII
- haskell
- ranges
- SHA512
- Scala
- type_traits
- Clojure
- WebView
- Android
- ChromeTab
- Functional
- go
- sprintf
- async
- kotlin
- Chrono
- coroutines
- traits
Archives
- Today
- Total
프로그래밍 검색 블로그
C++ ranges yield_if 본문
1 2 3 | vector<int> v = c >>= [](int e){ return yield_if(e % 2 == 0, e * 2); }; | cs |
for_each 혹은 yield를 사용할 조건식을 할때 첫번쨰 인자를 조건식으로 지정가능
즉 향상된 std::transform 기능이라고 봐도 무방할듯
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> #include <map> #include <vector> #include <range/v3/view.hpp> using namespace std; using namespace ranges; int main(){ vector<int> c = {1,2,3,4,5}; vector<int> v = c >>= [](int e){ return yield_if(e % 2 == 0, e * 2); }; cout << view::all(v) << endl; } | cs |
출력 :[4,8]
'C++ ranges' 카테고리의 다른 글
C++ ranges view::cycle (0) | 2017.10.08 |
---|---|
C++ ranges view::take (0) | 2017.10.08 |
C++ ranges view::for_each (0) | 2017.10.08 |
C++ ranges view::filter (0) | 2017.10.07 |
C++ ranges view::iota (0) | 2017.10.07 |
Comments