Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-05-31 09:15:22

In message <39351571.28284088_at_[hidden]>, Thomas Matelich
<sosedada_at_[hidden]> writes
>Kevlin Henney wrote:
>> In message <802568EF.00713157.00_at_[hidden]>, Jon Jagger
>> <jon.jagger_at_[hidden]> writes
>> >Hi,
>> >I'm sure it's just me not knowing some obscure corner of C++, but what is a
>> >mutable reference?
>> It's illegal, which saves having to dream up an interpretation for it
>> :->
>I've been waiting and waiting for some genius to explain this, so I'll have a
>stab at it. Mutable has nothing to do with what data type it modifies, mutable
>means that if the object is being accessed via a pointer-to-const, the mutable
>member may be modified. Note that a const member function basically says that
>"this" is now a pointer-to-const for the const function. More in depth
>analysis at:

Whilst this is all true, it answers the wrong question: it's not so much
a case of "what is mutable?" as "what is a mutable reference?". It's an
interesting concept, but not one that either makes sense or is legal
[7.1.1 para 8]:

"The mutable specifier can be applied only to names of class data
members (9.2) and cannot be applied to names declared const or static,
and cannot be applied to reference members."

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Ltd mobile: +44 7801 073 508
  kevlin_at_[hidden] fax: +44 870 052 2289

Boost list run by bdawes at, gregod at, cpdaniel at, john at