On Wednesday, 24 December 2014 at 13:39:00 UTC, aldanor wrote:
(especially when many such functions have been wrapped). Is it somehow possible to throw an exception "from the parent frame" so the backtrace would never drop into the template body?


Since this is just passed as arguments to the constructor, you can ask for the same argument in your function and forward them.

    auto check(alias func)(int x) {

Like make that

auto check(alias func)(int x, string file = __FILE__, size_t line = __LINE__) {
    /* snip */
throw new Exception("%d < 0".format(result), file, line); // L10


The default values are auto-filled by the compiler to be the call site, then you pass it on to Exception so when it prints, it shows that,

Reply via email to