June 2018
Intermediate to advanced
348 pages
8h 45m
English
The Streams library can work seamlessly with the STL containers. The following code snippets will map a function on Streams and resultant data is being transformed to a vector container:
//--------------- Streams_Third.cpp // g++ -I./Streams-master/sources Streams_Third.cpp // #include "Stream.h" #include <ioStream> #include <vector> #include <algorithm> #include <functional> #include <cmath> using namespace std; using namespace Stream; using namespace Stream::op; double square( double a ) { return a*a; } int main() { std::vector<double> values = { 1,2,3,4,5 }; std::vector<double> outputs = MakeStream::from(values) | map_([] (double a ) { return a*a;}) | to_vector(); for(auto pn : outputs ) { cout << pn << ...Read now
Unlock full access