
On 29/03/2011 19:51, Olaf van der Spek wrote:
On Tue, Mar 29, 2011 at 7:41 PM, Mathias Gaunard <mathias.gaunard@ens-lyon.org> wrote:
Using const void* allows the callee to easily pass whatever he wants, using iterator_range<const unsigned char*> requires him to do an ugly cast.
iterator_range also includes the terminator, which IMO is wrong.
iterator_range is a pair of iterators. In the case of iterator_range<const unsigned char*>, it's a pair of pointers.
It only includes what you instruct it to.
Use boost::as_literal to construct an iterator_range from a string literal.
Before: void f(const string&); f("Olaf"); After: void f(string_ref); f("Olaf");
I do not want to change the API and I certainly don't want callers to have to use boost::as_literal around every literal.
Then do struct string_range : boost::iterator_range<const char*> { string_range(const char* s) : boost::iterator_range<const char*>(boost::as_literal(s)) { } string_range(const char* first, const char* last) : boost::iterator_range<const char*>(first, last) { } };