> From: Peter Dimov [mailto:pdimov@mmltd.net]
> Sent: 07 August 2002 11:46
> From: "Anthony Williams" <anthwil@nortelnetworks.com>
> > > From: William E. Kempf [mailto:williamkempf@hotmail.com]
> > > Sent: 06 August 2002 19:17
> >
> > > From: "Peter Dimov" <pdimov@mmltd.net>
> > > Sent: Tuesday, August 06, 2002 12:42 PM
> >
> > > > References would need to be converted temporarily to
> > > pointers, but _seems_
> > > > possible.
> > >
> > > Through black magic, yeah ;). I can try and see if I can
> > > devise a solution
> > > here, though I'm not sure I've got the expertise to do so.
> >
> > For a reference type RT&:
> >
> > const volatile char* r; // as a data member
> >
> > // to call the function and capture the return
> > // add max cv-qualification to avoid having to know it
> > r=&reinterpret_cast<const volatile char&>(f());
> >
> > // to return the value
> > // cast back to an appropriate type with max cv-qualification
> > // then return to original cv-qualification
> > return const_cast<RT&>(reinterpret_cast<const volatile RT&>(*r));
>
> A cast to R* and back would be better. You can't cast
> function references to
> const volatile char &.
I had forgotten about function references. Looks like we'll need a special case for them (or for references to UDTs) --- the reason I used char* rather than R* is to avoid problems with user-defined operator&.
> Anyway, those are implementation
> details, even a
> version that doesn't handle reference return types would be
> sufficient as a
> proof of concept (making references work on MSVC 6/7 can be tricky.)
Agreed.
Anthony