Re: Const'ness


Subject: Re: Const'ness
From: sam th (sam@uchicago.edu)
Date: Sun Jul 09 2000 - 18:29:52 CDT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 10 Jul 2000, Mike Nordell wrote:

> Even without testing, AFAIK:
> The return of a temporary (which is what a return-value is) is (by the C++
> standard) not a modifiable l-value, and haven't been since at least
> Nov 1997 (the predefined macro '__cplusplus' using a conforming compiler is
> 199711L).
>
> What would make your statement true was if the function looked like:
> const int& foo();
> vs.
> int& foo();
>
> In fact, the declaration 'const int foo();' is meaningless, and might well
> emit a diagnostic message.

Well, that's what I get for pretending to know what I was talking
about. In my defense, I didn't really mean that const should be use to
protect you from modifiying the value of ints. I meant
pointers/references, even if I didn't say it. :-)
           
                                     sam th
                                     sam@uchicago.edu
                                http://www.abisource.com/~sam/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE5aQrxt+kM0Mq9M/wRArnHAJsElSftNRjwIrIawA1RJvjRjEQdHgCfcj8S
os/EpzNsTBIYMwzGvWEVlRE=
=qz1h
-----END PGP SIGNATURE-----



This archive was generated by hypermail 2b25 : Sun Jul 09 2000 - 17:26:01 CDT