lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Re: "consistent style for calling this->operator[]()" change


From: Vadim Zeitlin
Subject: [lmi] Re: "consistent style for calling this->operator[]()" change
Date: Thu, 26 Oct 2006 15:38:25 +0200

On Thu, 26 Oct 2006 13:19:26 +0000 Greg Chicares <address@hidden> wrote:

GC> 20061026T1315Z change: I don't see one way as better than another,
GC> so I used the style that predominates in HEAD.

 For the reference:

-        (*this)[child->get_name()] = xml_lmi::get_content(*child);
+        operator[](child->get_name()) = xml_lmi::get_content(*child);

GC> Perhaps this change is completely noncontroversial. If not, please
GC> open a discussion on the mailing list.

 I don't really want to open a huge discussion about it as the issue is
not very important, but I think the style using explicit "operator[]" is
rather unusual. I tried to prove it by searching for both patterns on
http://www.google.com/codesearch but ran into what seems like a bug: the RE
"operator\[\]\([^ ]*\)" results in a parsing error, so I couldn't filter
out all occurrences of declarations such as "T operator[](int i)". I
finally used the RE "operator\[\]\(\w*\)" to search for your version and
found ~3000 matches from which less than a half seem to be real examples of
its use judging from examination of the first few pages:

http://www.google.com/codesearch?q=operator%5C%5B%5C%5D%5C%28%5Cw*%5C%29&btnG=Search+Code

OTOH, searching for "\(\*this\)\[" found 4000 matches

http://www.google.com/codesearch?hl=en&lr=&q=%5C%28%5C*this%5C%29%5C%5B&btnG=Search

all of which seem to be valid.


 So it seems like Evgeniy's version is more common than the alternative
one, although by lesser margin than I thought. But note that projects such
as gcc libstdc++ and STLport do use (*this)[] and I think they're worth of
emulation.

 Regards,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]