More on % (managed reference)


Keith Duggar asked:


Ok, I’m missing a basic point here. So, out of curiousity:



1) Is there any overhead associated with using ‘T%’ in place of ‘T&’?


No.



2) Are there things that can be done with ‘T&’ that cannot be done with ‘T%’


Yes: A % can only exist on the stack (a CLI limitation). Cases where a C++ program puts a & on the heap are relatively rare — you’d have to a have a reference member of an object, which is problematic in general — but % can’t be a drop-in replacement for that use of &.


Comments (0)