built-in int[] opSliceOpAssign throws?

Jonathan M Davis jmdavisProg at gmx.com
Wed Sep 12 08:37:45 PDT 2012


On Wednesday, September 12, 2012 11:20:54 monarch_dodra wrote:
> This is a bug? I did not find any entries in Bug report. Should I
> report this?
> 
> I need to make the above call in a nothrow function. Is there any
> way to make it work, without any run-time cost?

I believe that dup and idup have the same problem, and it definitely needs to 
be fixed. Regardless, pretty much the only sane way to call a function that 
throws in a nothrow function is to put a try-catch around it.

try
   func();
catch(Exception e)
    assert(0, "func threw. That's supposed to be impossible.");

But if you do that, you'd better be sure that it really _can't_ throw (if it 
can, then you need to actually handle the exception rather than asserting 0).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list