
2 Apr
2011
2 Apr
'11
12:27 p.m.
On Tue, Mar 29, 2011 at 8:01 PM, Mathias Gaunard <mathias.gaunard@ens-lyon.org> wrote:
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) { } };
You don't want to repeat that bit of code in every app / lib you write. -- Olaf