Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dlang/phobos
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 65c7071bdec1332f2c027c8e499bc817ce6dc2e8
Choose a base ref
..
head repository: dlang/phobos
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5ebfe85ea11072225a3ab2f2147e4810fd7d09eb
Choose a head ref
Showing with 17 additions and 1 deletion.
  1. +17 −1 std/functional.d
18 changes: 17 additions & 1 deletion std/functional.d
Original file line number Diff line number Diff line change
@@ -1814,7 +1814,7 @@ if (isCallable!(F))
{
return fp;
}
else static if (is(F Func == Func*) && is(Func == function) && is(Func Params == __parameters))
else static if (is(F Func == Func*) && is(Func == function))
{
return () @trusted
{
@@ -1996,6 +1996,22 @@ private template buildDelegate(F)
assert(toDelegate(i2)(0xBED) == 0xBED);
}

@safe unittest
{
static void fun() @system pure nothrow @nogc
{
return;
}

auto fn = &fun;
static assert( is(typeof(fn) == void function() @system pure nothrow @nogc));
static assert(!is(typeof(fn) == void function() @safe pure nothrow @nogc));

auto dg = (() @safe => fn.toDelegate())();
static assert( is(typeof(dg) == void delegate() @system pure nothrow @nogc));
static assert(!is(typeof(dg) == void delegate() @safe pure nothrow @nogc));
}

/**
* Passes the fields of a struct as arguments to a function.
*