recently I was thinking about how it would be nice if iterators implicitly converted to bool so you could do
auto it = find(begin(x),end(x), 42);
if (it) //not it!=x.end();
{
}
but thinking about it I realized that this would mean that either it
would had to be set to "NULL", so that you couldnt use the it directly if you want to do something with it (you would have to use x.end()
) or you could use it but iter size would have to be bigger(to store if what it points to was .end()
or not).
So my questions are:
- Is the syntax in my example achievable without breaking current code and without increasing the sizeof iterator?
- would implicitly conversion to bool cause some problems?