this(this) must be cheap and O(1)

Trass3r un at known.com
Mon Sep 26 06:56:43 PDT 2011


> I'm fine with this, as long as it's not language-enforced, but just an  
> expectation.  Because there are sometimes reasons to break the rules.
>
> For example, you have said it's a faux pas to allocate memory inside a  
> postblit, but what if your "allocation" routine only allocates a pool on  
> the first call, and uses the pool for all the other allocations?  Or  
> guarantees to allocate at most once every 1000 postblits?  It's  
> difficult to make such guarantees generically, but within the context of  
> a specific application, it's quite easy to prove.
>
> I don't know if we need to enforce nothrow, but probably the easiest way  
> to find a case where you *need* to throw is to enforce nothrow, and see  
> what fallout we have ;)
>
> -Steve

+1


More information about the Digitalmars-d mailing list