Re: Why do Glib::ustring::operator[] and at() return values, not references?
- From: Daniel Boles <dboles src gmail com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Why do Glib::ustring::operator[] and at() return values, not references?
- Date: Wed, 28 Jun 2017 09:39:52 +0100
I wonder, would anyone be interested in adding a proxy class, to be returned by operator[] and .at() on a non-const ustring, which would provide operator gunichar() and operator=()? It would then hold a reference to the string and the index with which it was instantiated, and delegate to .replace() to do 'assignment'.
The benefits of this are:
- more intuitive/familiar
- could make ustring substitutable into code that currently uses std::string, or usable in template code to work on either
But the main drawback I could think of is this: It would change semantics for anyone currently using auto some_character = non_const_ustring[N], as the auto would now capture the proxy type, not a gunichar. To get the latter, the type would have to be explicitly specified to invoke the conversion operator. Or is there a clever way around this that I don't know?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]