Re: a question 'bout const (design)



On Fri, 30 May 2008 06:54:27 -0700 (PDT), ".rhavin grobert"
<clqrq@xxxxxxxx> wrote:

hello;-)

i've a little complex control-class with it's own worker-tread for
controls of that type. most control-setter-functions (for example: set
the background color, let an element blink, etc...) work like this:

1. someone calls a public fn.
2. public fn calls private static threadpost-wrapper.
3. threadpost-wrapper post ThreadMsg
4. control class worker UI thread does something stupid...

so, the question is:

the public fn that calls the wrapper actually *could* be marked const
as is just calls static and const fn. On the ohter hand, ive read
somewhere that i should try to have logical const-ness, not bitwise,
and a

MyObj::SetBackGround(whatever) const; doesnt look very logical, doesnt
it?

Nope.

So, what would YOU suggest? And where would be the benefits?

The constness of a wrapper function should follow whatever makes sense for
the wrapped function. If the function is SetX, it shouldn't be marked const
regardless of how it sets X.

--
Doug Harrison
Visual C++ MVP
.