Allow static lambdas using '&' to get the address to participate in function pointers calculation #4093
Answered
by
alrz
kyoyama-kazusa
asked this question in
Language Ideas
-
Method: unsafe void BubbleSort<T>(T[] array, delegate* managed<T, T, bool> comparer)
{
int length = array.Length;
for (int i = 0; i < length - 1; i++)
{
for (int j = 0; j < length - 1 - i; j++)
{
if (comparer(array[j], array[j + 1]))
{
var temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
} Caller: int[] a = { 3, 8, 1, 6, 5, 4, 7, 2, 9 };
BubbleSort(a, &(static (a, b) => a >= b)); Which is same as: // A static local function.
static bool localFunction(T a, T b) => a >= b;
BubbleSort(a, &localFunction); Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
alrz
Nov 1, 2020
Replies: 1 comment 1 reply
-
Duplicate of #3476 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
YairHalberstadt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Duplicate of #3476