
20 Apr
2012
20 Apr
'12
12:40 p.m.
On Friday 20 April 2012 14:15:50 Olaf van der Spek wrote:
Hi,
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"; assert(a); assert(b); return 0; }
I would prefer it to not compile. It is not clear what b should be initialized with because the "Olaf" argument can be interpreted as either an array of 5 characters or a string of 4 characters. If you wrap "Olaf" with as_literal, b should be initialized with true (because ranges are compired element-wise).