I hate to do this, but I think you totally misunderstood the point of the STL.
The fact that algorithms are separated from containers is a major feature of the STL and one of the major reasons why it is so awesome.
By having algorithms separated from containers you implement algorithms only once and only have to give your container the right properties to use (an) algorithm(s).
You reduce coupling and the chances for errors and bugs. When you need to switch to a different containers, you don't have to rewrite your code. You can also try different algorithms easily.
> if (123 in v)
I'm sorry but C++ is about describing precisely what you want to do and how you want it to be done to get the maximum performance out of your machine.
What is "in"? What does it do? How does it allocate memory? How can I get the position of the entry? Which algorithm is used to search for the entry? What must I do to support "in"?
On the other side,
> if (std::find(v.begin(), v.end(), 123) != v.end())
I use a O(n) algorithm to search from the beginning to the end of the container for an entry equal to 123.
The fact that algorithms are separated from containers is a major feature of the STL and one of the major reasons why it is so awesome.
By having algorithms separated from containers you implement algorithms only once and only have to give your container the right properties to use (an) algorithm(s).
You reduce coupling and the chances for errors and bugs. When you need to switch to a different containers, you don't have to rewrite your code. You can also try different algorithms easily.
> if (123 in v)
I'm sorry but C++ is about describing precisely what you want to do and how you want it to be done to get the maximum performance out of your machine.
What is "in"? What does it do? How does it allocate memory? How can I get the position of the entry? Which algorithm is used to search for the entry? What must I do to support "in"?
On the other side,
> if (std::find(v.begin(), v.end(), 123) != v.end())
I use a O(n) algorithm to search from the beginning to the end of the container for an entry equal to 123.