-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathevent_basic.cpp
More file actions
31 lines (26 loc) · 844 Bytes
/
Copy pathevent_basic.cpp
File metadata and controls
31 lines (26 loc) · 844 Bytes
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
29
30
31
/* Copyright 2019 Joaquin M Lopez Munoz.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See https://github.com/joaquintides/usingstdcpp2019 for talk material.
*/
#include <iostream>
#include <string>
#include "urp.hpp"
int main()
{
using namespace usingstdcpp2019::urp;
trigger<std::string> s;
auto n=s|map([](const std::string& s){return s.size();});
auto e=combine(s,n)
|filter([](const auto& p){return std::get<1>(p)>=4;})
|map([](const auto& p){return std::get<0>(p);})
|accumulate(std::string{},std::plus<>{});
e.connect([](const auto&,const std::string& str){
std::cout<<str<<" ";
});
for(const auto& str:{"welcome","to","using","std","cpp","2019"}){
s=str;
}
}