From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,604e0f87aa06eab6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-26 10:22:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-binary.blueyonder.co.uk.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.1.2418 Subject: Re: Imitation is the sincerest form of flattery From: Bill Findlay Newsgroups: comp.lang.ada Message-ID: References: <1048524746.273345@master.nyc.kbcfp.com> <1048530794.5794@master.nyc.kbcfp.com> <1048623730.801824@master.nyc.kbcfp.com> <8j838v81tn0t2ft4locfphs6tg6t7e1lvb@4ax.com> <1048691202.136151@master.nyc.kbcfp.com> <1ij38vsm381u560p0rmhenia606ggo9jpv@4ax.com> <1048698047.463797@master.nyc.kbcfp.com> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Wed, 26 Mar 2003 18:21:52 +0000 NNTP-Posting-Host: 80.195.75.181 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-binary.blueyonder.co.uk 1048702958 80.195.75.181 (Wed, 26 Mar 2003 18:22:38 GMT) NNTP-Posting-Date: Wed, 26 Mar 2003 18:22:38 GMT Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:35734 Date: 2003-03-26T18:21:52+00:00 List-Id: On 26/3/03 17:00, in article 1048698047.463797@master.nyc.kbcfp.com, "Hyman Rosen" wrote: > Anyway, in C++ you just need to have a conversion to > reference to element type in the proxy class. > > template > struct funky_array > { > struct index_proxy > { > funky_array &a; > int i; > index_proxy(funky_array &a, int i) : a(a), i(i) { } > operator Element &() { return a.get_element(i); } > }; > Element &get_element(int i) { /* find and return the element */ } > index_proxy operator[](int i) { return index_proxy(*this, i); } > }; > Hyman, could you explain what is going on in this rather obscure-looking code, for the sake of C++ non-gurus like me? -- Bill-Findlay chez blue-yonder.co.uk ("-" => "")