Topic: Cv-qualified references
Author: parthaspanda22@gmail.com
Date: Wed, 31 Oct 2007 10:51:59 CST Raw View
"Cv-qualified references are ill-formed except
when the cv-qualifiers are introduced through the use of a typedef
(7.1.3)"
I am unable to figure out an illustration of the above exception
that isnt like the following:
typedef int &iref_t;
const iref_t iref; // error
Can anyone help?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?iso-8859-1?q?Pedro_Lamar=E3o?= <pedro.lamarao@gmail.com>
Date: Wed, 31 Oct 2007 18:22:57 CST Raw View
On 31 out, 14:51, parthaspand...@gmail.com wrote:
> "Cv-qualified references are ill-formed except
> when the cv-qualifiers are introduced through the use of a typedef
> (7.1.3)"
>
> I am unable to figure out an illustration of the above exception
> that isnt like the following:
>
> typedef int &iref_t;
> const iref_t iref; // error
>
> Can anyone help?
Well... Your second line is an error, but not because of the const.
You must initialize every reference.
This example compiles in GCC 4.1:
typedef int& iref_t;
int i;
const iref_t iref = i;
To answer your actual question, the only variation to your example I
could think of would be to trade const for volatale (or const
volatile):
typedef int& iref_t;
int i;
volatile iref_t iref = i;
--
Pedro Lamar o
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]