5 ms·
I remember a university project where I used the >> (and <<) operators to "send" data between services. The code was a simulation of a parallel system with mul
by TrianguloY 3y ago
I remember a university project where I used the >> (and <<) operators to "send" data between services.
The code was a simulation of a parallel system with multiple services that sent messages between them, or something like that. Instead of using serviceA.send("hello",serviceB) you had something like serviceA >> "hello" >> serviceB.
I really loved that (my classmates not so much)
- puffybuf 3y agoI did something similar as a student, making my own exception class with std::ostream: throw exceptionC() << "error code: " << t; I often found myself having to format error strings for exceptions, so I thought I could just do it like cout in one line. I know now this is bad for i18n strings.
- rockwotj 3y agoGoogletest does this: http://google.github.io/googletest/primer.html#assertions http://google.github.io/googletest/primer.html#assertions
- codr7 3y agoWhy would you prefer that over: throw exceptionC("error code: ", t); ? Ever since perfect forwarding I've been using this pattern to get out of arrow hell: template <typename Arg, typename...Args> string to_string(Arg &&arg, Args &&...args) { stringstream buf; buf << arg; ((buf << std::forward<Args>(args)), ...); return buf.str(); }
- lioeters 3y agoReminds me of the ChucK operator. SinOsc b => Gain g => BiQuad f => dac; https://chuck.stanford.edu/doc/language/oper.html#chuck https://chuck.stanford.edu/doc/language/oper.html#chuck