Oleg Goldshmidt wrote:
Then you haven't understood my "dual existence" statement. Try out the following program:Oleg Goldshmidt <[EMAIL PROTECTED]> writes:
I stand by my posting so far.
Well, while it was making the round trip to the list and back, I also made a trip to the bookshelf to check myself. Item 15 of Scott Meyers's "Effective C++" confirms what I wrote: temps are const, and for the reasons I covered. It explicitly says that with a declaration like
C& C::operator=(C& rhs) { ... }
client code won't compile.
#include <iostream>
using namespace std;
class a { public: void function() const { cout<<"Const version called"<<endl; } void function() { cout<<"Non-const version called"<<endl; } static void func2( const a & ) { cout<<"Called with const reference"<<endl; } static void func2( a & ) { cout<<"Called with non-const reference"<<endl; } };
int main() { a().function(); a::func2(a());
return 0; }
A temp is a non-const, but it cannot be bound to a non-const reference. I don't like it, but that seems to be the case.
As for my original problem, upon retrospect (and a good night's sleep), I think that using "mutable" on the "owner" flag will be a better, cleaner, solution than using a proxy class.
Scott knows his stuff _much_ better than I do.
But the "Effective" series is fairly old. Older than the C++ ISO standard.
I know for a fact I did. However, this is for cases where you don't want to change the right side. In my case, as explained, I do want to change the right side. Still, as I wrote above, mutable would probably serve my needs better than the ugly hack.moreover, it is entirely possible (though I don't remember) that I learned that the rhs of the assignment should be const from his books.
I don't know ifWhile I don't have it, I did read both "Effective" and "More effective". Like I said, however, the only true source is the ISO standard, which is, sadly, not online (that I know of).
"Effective C++" is available on-line, so no URL.
Shachar
-- Shachar Shemesh Lingnu Open Source Consulting ltd. http://www.lingnu.com/
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
