3 ms·
as someone who knows C++, but doesn't use it everyday, nor keep up with the latest and greatest in the community, I was surprised to see the "pipe" syntax. It l
by untothebreach 12y ago
as someone who knows C++, but doesn't use it everyday, nor keep up with the latest and greatest in the community, I was surprised to see the "pipe" syntax. It looks like the author is using them like unix pipes, or like the `|>` macro in Elixir. When did C++ get this? Is it just functions overloading the bitwise-or operator, or is it 'official' syntax?
- Rexxar 12y agoIt is just functions overloading the bitwise-or operator. It's already widely use in boost::range library. (http://www.boost.org/doc/libs/1_57_0/libs/range/doc/html/range/reference/adaptors/introduction.html http://www.boost.org/doc/libs/1_57_0/libs/range/doc/html/ran...)
- untothebreach 12y agothanks for the clarification!
- pmr_ 12y agoThis is achieved by overloading the operator|, although there is some special hackery to use static function objects to omit the constructor calls. The first mayor library to use this syntax was Boost.Range and it is now being proposed as the syntax of standard ranges.
- untothebreach 12y agothanks!
- eric_niebler 12y agoActually, the authors of Boost.Range got the idea from an earlier range library of mine, which is noted in the Acknowledgements section of the Boost.Range documentation [here](http://www.boost.org/libs/range/doc/html/range/history_ack.html http://www.boost.org/libs/range/doc/html/range/history_ack.h...): > Eric Niebler contributed the Range Adaptor idea which is arguably the single biggest innovation in this library.