C++/CLI pin_ptr

2019-07-07 03:23发布

问题:

Is C++/CLI's pin_ptr the equivalent of C#'s fixed statement?

回答1:

Yes, pretty much.

Some differences:

  1. A fixed statement creates its own scope block. pin_ptr's scope is from its initialization to the end of the enclosing block.
  2. fixed is an explicit language feature. pin_ptr is a use of a general language feature (C++ templates).(See comments.)

There are probably more differences like the above. But, when translating between the two languages, they are generally equivalent.



标签: c# c++-cli