🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2232

Re: Need an operator ->[]

#2232
From: Sean A Corfield
Date: Wed, 18 Oct 1995 13:10
33 lines
1469 bytes
In article <461ref$hfr@sake.wwa.com>,
Shashaanka <shashank@sashimi.wwa.com> wrote:

|> X x;
|> X * x1=x;

Firstly, I'll assume you mean:

	X* x1 = &x;

|> However, a more natural way could be to use it like
|> x1->[10].
|> 
|> Would like your comments on this, or if there are alternatives.

I'm not sure I like your proposed syntax but why not use a reference
instead?

	X& x2 = x;
 x2[10];

[shared memory justification snipped]
You could still use references even when pointers would seem natural due to
allocation:

 X& x3 = *new X[10];
 x3[10];   // invoke X::operator[], return int
 (&x3)[9]; // invoke builtin [] on X*, return X&
 delete[] &x3;
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <ACAA6EF196682CDFE@corf.demon.co.uk>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <45tv4c$opc@news.csus.edu> <45uf98$dqt@jabba.lehman.com> <461ref$hfr@sake.wwa.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 18 Oct 95 13:10:34 GMT
Approved: fjh@cs.mu.oz.au
From: Sean A Corfield <sean@corf.demon.co.uk>
Newsgroups: comp.std.c++
Subject: Re: Need an operator ->[]
X-Original-Date: Wed, 18 Oct 1995 08:44:33 +0100
Organization: OCS
Message-ID: <ACAA6EF196682CDFE@corf.demon.co.uk>
References: <45tv4c$opc@news.csus.edu> <45uf98$dqt@jabba.lehman.com> <461ref$hfr@sake.wwa.com>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIT82+EDnX0m9pzZAQGzQgGAlij7QxqaA/7pxgDSQGDrFpKbuyur0/oF
 vwdI0B1/0rsMyjh8ZwSWJqIRTkzBheYF
 =SA3F