News for hackers. Stuff that matters.
Re:Looking at C++14 by pfultz2 on Saturday March 15, 2014 @02:47PM (#7405703)
> If in is an operator and overloaded by std::vector, then it's easy to implement.

However, searching a `std::vector` is not really part of its implementation. So, requiring every single range to overload an operator for trivial searching is not good, especially since there are only a few containers that have non-trivial searching.

Instead, the range-based find could be specialized for containers that have non-trivial searching instead(perhaps it calls a `.find` method if available otherwise it does trivial searching).

In [Linq](http://pfultz2.github.io/Linq/), the find is specialized for mapped containers and for strings(it doesn't check for a `.find` method since that can't be done on msvc). So you can search a `std::vector` like this:

    std::vector<int> v = { ... };
    auto it = v | linq::find(123);
And you can also search the keys of a map like this:

    std::map<int, std::string> m = { ... };
    auto it = m | linq::find(123);
Plus, it has a contains function, so you can do this:

    if (v | linq::contains(123))
Or this:

    if (m | linq::contains(123))
There really is no need for a new operator just for this, since a function will suffice. However, if you really inclined to this, you could always write your own [named operator](https://github.com/klmr/named-operator)(although I don't know if it would become standard):

    if (123 <in> v)
Re:Looking at C++14 by halayli on Saturday March 15, 2014 @05:20PM (#7406508)
You can say the same thing for the new range based for loop in C++11.