Thread overview
[Issue 14196] opApply and nothrow don't play along
Dec 29, 2020
Bolpat
Dec 29, 2020
Mathias LANG
Dec 17, 2022
Iain Buclaw
August 06, 2015
https://issues.dlang.org/show_bug.cgi?id=14196

Илья Ярошенко <ilyayaroshenko@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ilyayaroshenko@gmail.com

--- Comment #1 from Илья Ярошенко <ilyayaroshenko@gmail.com> ---
Blocks PR https://github.com/D-Programming-Language/phobos/pull/3397

--
April 01, 2016
https://issues.dlang.org/show_bug.cgi?id=14196

qs.il.paperinik@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--
December 29, 2020
https://issues.dlang.org/show_bug.cgi?id=14196

--- Comment #2 from Bolpat <qs.il.paperinik@gmail.com> ---
You can overload on attributes:

struct MyArray(T)
{
    int opApply(scope int delegate(ref T)         dg);
    int opApply(scope int delegate(ref T) nothrow dg) nothrow;
}

This is not DRY and if the code inside opApply might throw depending on T, the
second overload won't compile.
Using templates breaks generic code that omits the foreach variables' types
(which is what generic code usually does).

If your case is only about nothrow (or any other single attribute), you can
define a template
    int opApplyImpl(DG)(scope DG dg)
and alias opApply to specific instantiations:
    alias opApply = opApplyImpl!(int delegate(ref T)        );
    alias opApply = opApplyImpl!(int delegate(ref T) nothrow);
Whether this solution is viable or not depends on details of your case.

--
December 29, 2020
https://issues.dlang.org/show_bug.cgi?id=14196

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
For reference, I mentioned a solution to this problem which I'm working on during DConf: https://www.youtube.com/watch?v=9lOtOtiwXY4

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14196

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 13
https://issues.dlang.org/show_bug.cgi?id=14196

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17698

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--