|
Why "probably", CPallini?
I quote what you said, and you should be sure about what you mean.
regards,
George
|
|
|
|
|
George_George wrote: Why "probably", CPallini?
It depends on T1 public interface, we don't know about.
George_George wrote: I quote what you said, and you should be sure about what you mean.
If you quote my words, you should include "that is going on his arrogant assumptions..."
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
Makes senses.
regards,
George
|
|
|
|
|
Since when is rolling back an inherent feature of an assignment operator? I don't remember seeing that in Effective C++ or anywhere else.
led mike
|
|
|
|
|
I think he means a logical concept of "rollback", i.e. keep the status of object consistent (e.g. original).
regards,
George
|
|
|
|
|
rollback is not consistent with the implied contract of an assignment. At least I'm pretty sure it isn't on the plant I come from. I'm not really sure where I am at this moment.
Have you read Meyers?
led mike
|
|
|
|
|
led mike wrote: At least I'm pretty sure it isn't on the plant I come from
Nuclear plant?
led mike wrote: Have you read Meyers?
Nope, chemistry [^] is not my favourite topic.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks led mike,
Then, how do you understand the statement "cannot in general roll back the change already made to t1_", why can not?
regards,
George
|
|
|
|
|
led mike wrote: is rolling back an inherent feature of an assignment operator
Who said that?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You did. "is not the whole scenario: it maybe also impossible to roll back"
CPallini wrote: You're interpretation is correct, but is not the whole scenario: it maybe also impossible to roll back becauseT1 class public interface simply doesn't allow it.
led mike
|
|
|
|
|
OK, if you throw, then you're going to leave Widget object in inconsistent state?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Ok and rolling back would be equal to inconsistent, not a solution to it.
led mike
|
|
|
|
|
led mike wrote: Ok and rolling back would be equal to inconsistent, not a solution to it.
Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
a = 5;
a = 12;
Now you expect the value of a to be 12, period. If it were 5 it's inconsistent since you don't expect it to be 5 any more than you expect it to be some random value due to an exception being thrown.
However I strongly suggest you buy and read Meyers[^] on Effective C++ and More Effective C++, I am a consumer not an author.
led mike
|
|
|
|
|
Off course you made an example using built in types, not complex objects.
Anyway I'll probably follow your suggestions, the books look interesting.
BTW a random value is not an inconsistent state for int .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Whatever. You just keep thinking whatever you want, I no longer care.
led mike
|
|
|
|
|
led mike wrote: Whatever. You just keep thinking whatever you want, I no longer care.
Of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Does led mike mean rollback is not needed in assignment operator if exception is thrown?
regards,
George
|
|
|
|
|
Yes. Though I don't know if is he or Scott Meyers
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi CPallini,
If no rollback when exception thrown in assignment operator, how could we make sure strong exception safe.
regards,
George
|
|
|
|
|
Well, I'm not an expert, however the article of your OP explain very well how to do that by expoiting the Pimpl Idiom , but shhhhhhhhhh, don't tell led mike.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Agree, CPallini! Let us wait for led mike to see how could he give us a strong exception safe assignment operator without change the class structure to Pimlp Idiom.
regards,
George
|
|
|
|
|
CPallini wrote: Yes.
No. See my reply to George. And yes it is from Meyers. Wink while you can monkey boy.
led mike
|
|
|
|
|
Post conditions are required by design by contract approach, or am I wrong?
led mike wrote: Wink while you can monkey boy.
Please elaborate (my poor English).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: Post conditions are required by design by contract approach, or am I wrong?
Yes, no, both. assignment operator, and other other operators, have implicit contracts. Read Meyers. ( I am getting a little tired of saying the "read Meyers" part you know )
CPallini wrote: Please elaborate (my poor English).
It's a twist on a quote from a movie Adventures of Buckaroo Banzai Across the 8th Dimension[^] where a character said "Laugh while you can monkey boy".
led mike
|
|
|
|