|
-
January 20th, 2004, 11:34 AM
#11
Originally posted by treuss
My post is in hope of finding a third way to get rid of both evils: const_cast's AND duplicate code.
I think this is both a noble and a resonable goal. I believe Yves had the right idea about how to implement the const function. The problem is that you had compiler errors when doing that. Since you have two functions that work -- one without the const constraint and one with the const constraint -- I would attempt to use the code that implements the const-constraint for both cases. If there was some problem with that, I would look at the differences between the two functions, investigate those differences and then refactor. I want to emphasize though that my first attempt would be just to cut-and-paste my code that has the const-constraints into the function that does not require it per-se. If it compiles fine, then you can implement Yves' suggestion and be done with it!
- Kevin
P.S. If you have the time, then refactoring is usually good -- especially for this problem.
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
|