4 ms·
> The issue with extending operators in this fashion is that you're violating the principle of least surprise. It is really common for the `|` operator to be u
by pfultz2 12y ago
> The issue with extending operators in this fashion is that you're violating the principle of least surprise.
It is really common for the `|` operator to be used for piping functions together. There are several libraries that support it: [Boost.Range](http://www.boost.org/doc/libs/1_56_0/libs/range/doc/html/index.html http://www.boost.org/doc/libs/1_56_0/libs/range/doc/html/ind...), [PStade Oven](http://p-stade.sourceforge.net/oven/doc/html/index.html http://p-stade.sourceforge.net/oven/doc/html/index.html), [Linq](http://pfultz2.github.io/Linq/ http://pfultz2.github.io/Linq/), and [Streams](http://jscheiny.github.io/Streams/ http://jscheiny.github.io/Streams/). Plus, its even being proposed as part of the ranges library in future C++: https://github.com/ericniebler/range-v3/blob/master/doc/D4128.md https://github.com/ericniebler/range-v3/blob/master/doc/D412...
So just as the bit shift operators in C++ also have the meaning of streaming in and out, the bitwise or also has the meaning of pipe, so this is should not at all be a suprise.
- jschwartzi 12y agoInteresting. I was not aware of this, so thank you.