c++ "with" keyword
Erik Schnetter
schnetter@uni-tuebingen.de
Sun Dec 29 06:49:00 GMT 2002
The example
struct S
{
int x;
int y;
};
int main()
{
S s;
with (s)
{
.x = 1;
.y = 2;
}
return 0;
}
can easily be rewritten by introducing temporary references, as in
int main()
{
S s;
{
S& t = s;
t.x = 1;
t.y = 2;
}
return 0;
}
This requires only one additional variable reference each time the
"with" object is used. Additionally, it allows several "with" objects
(with different names) at the same time. In C, the same thing can be
done by using pointers.
-erik
--
Erik Schnetter <schnetter@uni-tuebingen.de>
Web: http://www.tat.physik.uni-tuebingen.de/~schnette/
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from www.keyserver.net.
More information about the Gcc
mailing list