Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-07 05:46:23


From: "Anthony Williams" <anthwil_at_[hidden]>
> > From: William E. Kempf [mailto:williamkempf_at_[hidden]]
> > Sent: 06 August 2002 19:17
>
> > From: "Peter Dimov" <pdimov_at_[hidden]>
> > 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 &. 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.)


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