On Thursday, 20 July 2017 at 15:10:24 UTC, Aldo wrote:
On Thursday, 20 July 2017 at 14:59:50 UTC, Steven Schveighoffer wrote:
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

Im using DerelictGLFW3, to process events im doing this :

glfwSetMouseButtonCallback(window, &onMouseClick);

onMouseClick function must be nothrow.

But now I can't do anything in this function because I can't convert my code to nothrow.

Can I put a try catch in the body ?

extern(C) nothrow
{
void onMouseClick(GLFWwindow* window, int button, int action, int d)
    {
       try
       {
           // my code
       }
       catch
       {

       }
    }
}

it seems its working but what about performances ?

thanks

You could also try assumeWontThrow. https://dlang.org/library/std/exception/assume_wont_throw.html

Reply via email to