From 7883719297396269000
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,1e33266bee377e
X-Google-Attributes: gidf78e5,public
From: Pierre Baillargeon <pb@artquest.net>
Subject: Re: mutable member data vs. mutable functions
Date: 2000/08/25
Message-ID: <39A67792.848DEE87@artquest.net>#1/1
X-Deja-AN: 662512995
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <39A14420.F81235AA@bellatlantic.net>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=iso-8859-2
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 967237520 mail2news:22235 mail2news mail2news.demon.co.uk
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
MIME-Version: 1.0
NNTP-Posting-Date: Fri, 25 Aug 2000 09:40:25 EDT
Newsgroups: comp.std.c++

Carl Nygard wrote:
> 
> Is there any reason why the mutable concept wasn't extended to
> functions?

You can get the same behavior by writing a private base class which
declares the member mutable and provides the member functions you would
wish to have your new mutable keyword. Then provide access member
functions that provide const read-access and non-const write access.
Make it all inline if you are concerned with speed.


As for the legitimacy of using mutable in this context, I find it
completely justified, as the fact that the fraction is simplified or not
does not change its logical value. So I disagree with Mr. Nicolet
opinion. What's more, simplifying the fraction at each modification
would slow down calculations considerably, since it would need to be
done at each and every step. It all depends on whether it is part of a
library, which should take reasonable time to provide an efficient
implementation, vs. a single-use class, which can be optimized only if
needed.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]




