Allowing ref types as type arguments for type parameters accept ref struct types #8067
Unanswered
hez2010
asked this question in
Language Ideas
Replies: 2 comments 2 replies
-
Consider void Foo<T>(ref T arg) where T : allows ref struct { } What is the signature of |
Beta Was this translation helpful? Give feedback.
1 reply
-
Isn't that covered by #5321? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With the support for ref struct for interfaces and type arguments, we are now able to emulate
ref
in type argument via creating our own ref struct with a ref field.The above code will be able to compile and work fine.
I suggest allowing passing
ref T
to a type parameter which allows ref struct as its type argument as well, so that the above code can be:A typical use case of this is that we can now pass
ref T
as the type argument ofAction<T>
andFunc<T>
without need of lowering to an unspeaking delegate type:Prototype of runtime support for this: dotnet/runtime@main...hez2010:byref_generics
Beta Was this translation helpful? Give feedback.
All reactions