<br><br><div class="gmail_quote">On Thu, Sep 27, 2012 at 12:51 AM, Ladislav Nevery <span dir="ltr"><<a href="mailto:neuralll@gmail.com" target="_blank">neuralll@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Actually the sample you provided will work without problem.<br>
Since switch works only on first assign(after default constructor)<br>
<br>
TextFile textfile[1000]; // default constructor doing nothing<br>
<br>
textfile[1]=TextFile("c:\test1.txt"); // = we call destructor doing nothing<br>
and placement new<br>
textfile[1]=TextFile("c:\test1.txt"); // standard temp copy + operator combo<br>
<br>
But I see the point if you put code logic to default constructor then yes<br>
first assign will not happen. You use switch to remove copy from arrays<br>
init. So yes actual code change is needed in this statistically marginal<br>
case.<br>
<br>
Anyway code logic (opening files etc) in default constructors is BLASPHEMY !<br>
:D such people actually deserve to being punished.<br>
Punishing them a bit more is actually good thing ;D Lets call it feature<br></blockquote><div><br></div><div>I'm sorry I don't understand at all what you mean here.</div><div>I'm saying, taking the exact code I proposed, not changing it by adding a default constructor, this expression:</div>
<div><br></div><div>TextFile a ("a.txt");<br>TextFile b ("b.txt");<br>a = b; //copy the content of b.txt in a.txt<br><br>Would have, using your change, a different semantic than what the standard propose because there would be file closing and opening where I didn't want to.</div>
<div>The type is specifically written to avoid closing and opening files until the instances are really out of scope or explicitely deleted.</div><div><br></div><div>Or did I misunderstand your proposal?</div><div><br></div>
<div>Joel Lamotte</div></div>