Topic: draft change? const types for templates
Author: jpotter@falcon.lhup.edu (John Potter)
Date: 1997/05/11 Raw View
On 10 May 1997 12:12:23 -0400, Paul D. Derocco wrote:
: John Potter wrote:
: > (double&)x; // lets pretend that x is a double
: Is that real? I've always done *(double*)&x instead. You're saying in
: C++ I can interpret the bits of x as a double by simply casting it to a
: double& ?
Yep, see 5.2.10[expr.reinterpret.cast]/11 which esentially says, if it
works for pointers, it words for references.
double x(0);
reinterpret_cast<int&>(x) = 5;
That's what the draft says; however, one of my compilers actually sets
x to 5.0 while my others correctly produce garbage.
John
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]