We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
toDelegate
opCall
1 parent 8c6fca9 commit 4c4c37aCopy full SHA for 4c4c37a
std/functional.d
@@ -1819,6 +1819,10 @@ if (isCallable!(F))
1819
{
1820
return toDelegate(&fp.opCall);
1821
}
1822
+ else static if (is(typeof(&fp.opCall!())))
1823
+ {
1824
+ return toDelegate(&fp.opCall!());
1825
+ }
1826
else
1827
1828
alias DelType = typeof(&(new DelegateFaker!(F)).doIt);
@@ -1949,6 +1953,20 @@ if (isCallable!(F))
1949
1953
1950
1954
1951
1955
1956
+
1957
+@system unittest
1958
+{
1959
+ static struct S1 { static void opCall()() { } }
1960
+ static struct S2 { static T opCall(T = int)(T x) {return x; } }
1961
1962
+ S1 i1;
1963
+ const dg1 = toDelegate(i1);
1964
+ dg1();
1965
1966
+ S2 i2;
1967
+ assert(toDelegate(i2)(0xBED) == 0xBED);
1968
+}
1969
1952
1970
/**
1971
* Passes the fields of a struct as arguments to a function.
1972
*
0 commit comments