ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.06k stars 396 forks source link

Create iterate error commit 562 "[Perfomance] Significantly reduce amount of copies/moves inside operators" #600

Closed TKNgu closed 1 year ago

TKNgu commented 1 year ago

`#include "rxcpp/rx.hpp"

include "rxcpp/rx-test.hpp"

include

namespace rxu=rxcpp::util;

include

//#include

int main() { std::array< std::string,4 > a={{"Praseed", "Peter", "Sanjay","Raju"}}; auto values = rxcpp::observable<>::iterate(a).flat_map( [] (std::string v ) { std::array<std::string,3> salutation ={ { "Mr." , "Monsieur" , "Sri" }}; return rxcpp::observable<>::iterate(salutation); }, [] ( std::string f , std::string s ) { return s + " " +f; }); values.subscribe( [] (std::string f) { std::cout << f << std::endl; } , [] () {std::cout << "Hello World.." << std::endl;} ); }` New commit output:

Mr. Praseed Monsieur Mr. Peter Sri Monsieur Mr. Sanjay Sri Monsieur Mr. Raju Sri Monsieur Sri Hello World..

Release version v4.1.1 Mr. Praseed Monsieur Praseed Mr. Peter Sri Praseed Monsieur Peter Mr. Sanjay Sri Peter Monsieur Sanjay Mr. Raju Sri Sanjay Monsieur Raju Sri Raju Hello World..