Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2003-04-16 08:25:17


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.

[3] const T & const ref;
both reference and data type are constant.

However, when compiling the third form, I run into differing opinions by
compilers:
* Borland C++Compiler 5.5.1 accepts it without warnings or errors;
* Microsoft VC 7.0 issues a warning along the lines of:
   "anacronism used : disregarding additional qualifiers"
* GCC 3.0.3 gives a message saying that it is disregarding the extra
'const' on the reference, and fails to produce a .o object file (at least it
does on the tests that I have done, although I'm no GCC expert)

Does anyone else have similar experiences? Am I wrong? Should I use the
second form instead of the third?

Is there a way to get GCC to compile the third form without halting object
code generation?

-rhd-

_________________________________________________________________


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk