1+ #include < nodepp/nodepp.h>
2+ #include < nodepp/event.h>
3+
4+ #include < string>
5+ #include < queue>
6+ #include < vector>
7+ #include < functional>
8+
9+ using namespace nodepp ;
10+
11+ void onMain (){
12+
13+ ptr_t <int > ptr ( 0UL , 10 ); // as value
14+ // ptr_t<int> ptr ( 1UL, 10 ); // as buffer
15+
16+ /* -----*/
17+
18+ std::function<void (int )> clb ([=]( int value ){
19+ console::log ( value, *ptr );
20+ });
21+
22+ /* -----*/
23+
24+ event_t <int > ev; ev.once ( clb );
25+ ev.emit ( 100 );
26+
27+ /* -----*/
28+
29+ std::string str = " hello world" ;
30+ console::log ( " >>" , str );
31+
32+ /* -----*/
33+
34+ std::vector<int > arr ({ 10 , 20 , 30 , 40 , 50 });
35+ console::log ( " >>" , array_t <int >( arr ).join () );
36+
37+ /* -----*/
38+
39+ std::queue<int > st ({ 10 , 20 , 30 , 40 });
40+ queue_t <int > que ( st );
41+ que.map ([=]( int value ){ console::log ( " <>" , value ); });
42+
43+ /* -----*/
44+
45+ std::string str2 = " hello world" ;
46+ ptr_t <std::string> ptr1 ( 0UL );
47+ *ptr1 = type::move ( str2 );
48+ console::log ( *ptr1 );
49+
50+ /* ----*/
51+
52+ std::vector<int > vec ({ 10 , 20 , 30 });
53+ ptr_t <int > ptr2 ( 3UL );
54+ type::move ( vec.begin (), vec.end (), ptr2.begin () );
55+ console::log ( array_t <int >( ptr2 ).join () ); // <- cheap for the CPU
56+
57+ }
0 commit comments