This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: generalized lvalues -- patch outline
Matt Austern <austern@apple.com> writes:
| One oddity I've found is that CW allows this:
| int x;
| int* p = x;
| char c;
| (char*) p = &c;
|
| but not this:
| int x;
| (char) x = 'a';
|
| And, as I said, they do choose the correct overload when you pass
| ((char*) p) to a function that's overloaded on char*& and char*
| const&.
I'm surprised that such efforts are being spent to resurect that
abomination, when the C++ language already made clear provisions
int x;
int* p = x;
char c;
reinterpret_cast<char*&>(p) = &c;
or
int x;
reinterpret_cast<char&>(x) = 'a';
to mark those dubious constructs.
I offer
template<class T, class U, class T>
inline void
sheat(U& u, V v)
{
reinterpret_cast<T&>(u) = v;
}
as a free replacement of that abomination resurection.
Please, let's keep this straight. It is already in the language; we
do not need to overload existing syntax in a way that conflict with
standard semantics.
cast-as-lvalue must go.
-- Gaby