opEquals nothrow

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 20 07:59:50 PDT 2017


On 7/20/17 10:38 AM, Aldo wrote:
> Hello,
> 
> im tring to add nothrow keyword in my code, but compilation fails :
> 
> function 'object.opEquals' is not nothrow
> 
> 
> its a simple comparison between 2 objects. How to make opEquals nothrow ?

You can't. Object.opEquals is not nothrow, so object.opEquals is not 
nothrow (note the former is the virtual member function, the latter is a 
global function which is what the compiler actually calls).

It is a legacy limitation. Until we get rid of all the Object base 
methods for things like opEquals and toHash, we will not be able to fix 
this.

-Steve


More information about the Digitalmars-d-learn mailing list