Boost logo

Boost :

From: Anthony Williams (anthwil_at_[hidden])
Date: 2002-08-19 03:49:59


David Abrahams writes:
> 8c0_at_[hidden]><006a01c24528$8b790dd0$1d00a8c0_at_pdimov2><15709.1022.799000.496818_at_gargle.gargle.HOWL><006101c24619$40c34160$6501a8c0_at_[hidden]>
> <005501c2461f$671a1bd0$1d00a8c0_at_pdimov2>
> Subject: Re: [boost] Iterator adaptors return a value from operator[]?
> Date: Sat, 17 Aug 2002 15:25:01 -0400
> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="Windows-1252"
> Content-Transfer-Encoding: 7bit
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Mailer: Microsoft Outlook Express 6.00.2600.0000
> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> X-BeenThere: boost_at_[hidden]
> X-Mailman-Version: 2.1b1
> Precedence: bulk
> List-Help: <mailto:boost-request_at_[hidden]?subject=help>
> List-Post: <mailto:boost_at_[hidden]>
> List-Subscribe: <http://lists.boost.org/mailman/listinfo.cgi/boost>,
> <mailto:boost-request_at_[hidden]?subject=subscribe>
> List-Id: Boost mailing list <boost.lists.boost.org>
> List-Unsubscribe: <http://lists.boost.org/mailman/listinfo.cgi/boost>,
> <mailto:boost-request_at_[hidden]?subject=unsubscribe>
> List-Archive: http://lists.boost.org/MailArchives/boost/
> Errors-To: boost-bounces_at_[hidden]
> X-SMTP-HELO: heart-of-gold.osl.iu.edu
> X-SMTP-MAIL-FROM: boost-bounces_at_[hidden]
> X-SMTP-RCPT-TO: anthwil_at_[hidden]
> X-SMTP-PEER-INFO: heart-of-gold.osl.iu.edu [129.79.245.244]
>
> From: "Peter Dimov" <pdimov_at_[hidden]>
>
>
> > From: "David Abrahams" <dave_at_[hidden]>
> > >
> > > We've thought about it, and haven't come up with an answer. The details
> > > (like the fact that operator[] might be overloaded, which pretty much
> > rules
> > > out the approach above) are non-trivial. If /you/ can fill in the
> details,
> > > I'm interested. I've already tried and failed.
> >
> > For non-const iterators,
> >
> > yes test(value_type &);
> > no test(...);
> >
> > test(a[i]);
> >
> > For const iterators, the technique doesn't work, but return by value
> works
> > adequately there.
>
> That's not legal in the case where a[i] is a non-POD value type, is it? I
> thought that passing a non-POD to a ... argument invokes undefined
> behavior.

Only if you actually make the call...

sizeof(test(a[i])) is well-defined.

Anthony


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk