|
-
November 9th, 2009, 05:33 PM
#3
Re: howto restric a method to being absolutely constant
 Originally Posted by kempofighter
if you want a functor to be "read-only" make its operator(), function arguments, and any other private members const and the compiler will ensure that you aren't modifying anything.
I think what OP wants is something similar to
Code:
void operator()(const Target& obj) const
where the const in red won't get caught by the compiler if any modification is done on the argument.
(which I totally agree with you that it doesn't make sense)
@ssouffri
AFAIK, there's no such thing as "absolute const" for you can a) cast it away,
b) make certain members mutable.
I don't know much about pthread or boost thread functions,
but for win32 api,
even if you some how make the method "absolute const",
the chance is that you will likely pass object as the argument,
in which case data passed to the thread function
Code:
void operator()(const Target& obj) const
{
tHandle = (HANDLE)_beginthreadex(NULL, 0, &obj.dispatch, &obj, 0, &tID);
}
would require, some type of conversion,
of which, the conversion is impractical to pursue or non-thread safe.
I think you have to rely on the design more,
and implement necessary synchronization.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|