Why foreach is not nothrow even for a simple associative array?

Steven Schveighoffer schveiguy at yahoo.com
Thu Oct 13 04:50:42 PDT 2011


On Thu, 13 Oct 2011 06:16:59 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Cheng Wei:
>
>> The problem is that if we tag _aaApply2 as nothrow, then can we still
>> put throwable codes in the body of foreach?
>
> I see. Now in D there is purity/"throwbility" inference for templates.  
> Is _aaApply2 allowed to become a template?

No, but I see no reason why _aaApply2 couldn't be overloaded with  
nothrow/pure versions.  The underlying code would probably be a template  
since the actual code is no different.

-Steve


More information about the Digitalmars-d-learn mailing list