Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • @Dave: Note that the return type can be const, too. It doesn't make much sense for a built-in, since rvalues of built-in type cannot be modified anyway, but it's not really "wrong". Commented Oct 17, 2009 at 18:26
  • @Scott: What do you mean "it doesn't work"? This is the idiomatic and canonical form of overloading operator[], so if this doesn't work, you'd better find out why and fix that. Commented Oct 17, 2009 at 18:27
  • Sbi: It's "wrong" in that then it doesn't mean what we want it to mean; it means something different. It wouldn't be wrong if we wanted that other meaning, but we don't. Commented Oct 17, 2009 at 18:30
  • @Dave: It was another disqualifier error. I found just avoiding accessing the operator[] all together when under the const umbrella solved my problem -- by using an accessor to retrieve chars_. Commented Oct 17, 2009 at 18:59