|
Boost : |
From: Matthew Towler (towler_at_[hidden])
Date: 2003-04-16 09:42:39
Reece Dunn wrote:
> If I understand the ISO/IEC C++98 standard correctly:
>
> [1] const T & ref;
> means that the data type referred to by ref is constant (i.e. you
> cannot modify its internal state).
>
> [2] T & const ref;
> means that the *reference* is constant.
No, I don't think you do understand the standard correctly.
This form [2] does not mean anything different from [1], references are
implicitly constant in that you cannot 'reseat' them. e.g.
int a, c;
int& b = a;
b = c; // error, as attempting to reseat the reference.
This means that VC++7 is correct in warning "anacronism used :
disregarding additional qualifiers". It also means form [3] is
pointless as well.
If you want something you can reseat, and that does have the 3 forms you
describe, then you need to use pointers.
Matt
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk