Subject: Re: [boost] Iterator Range and operator==
From: Thijs (M.A.) van den Berg (thijs_at_[hidden])
Date: 2012-04-20 08:36:07
> What do you expect this code to do? Is b true or false? And why?
> Is this expected behaviour?
> #include <boost/range/iterator_range.hpp>
> #include <string>
> int main()
> std::string s = "Olaf";
> boost::iterator_range<std::string::iterator> r(s);
> bool a = r == s;
> bool b = r == "Olaf";
> return 0;
I would expect both a and b to false since one side is an iterator range, and the other a string. However, I would also expect s == "Olaf"; to be false because one is std::string and the other a string constant. It all depends on how you define equality. Do both sides need to be the same type, do they only have to have same content, does the content need to be at the same memory location? It all depends on the interpretation of equality.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk