问题
Is C++/CLI's pin_ptr the equivalent of C#'s fixed statement?
回答1:
Yes, pretty much.
Some differences:
- A
fixed
statement creates its own scope block.pin_ptr
's scope is from its initialization to the end of the enclosing block. fixed
is an explicit language feature.(See comments.)pin_ptr
is a use of a general language feature (C++ templates).
There are probably more differences like the above. But, when translating between the two languages, they are generally equivalent.
来源:https://stackoverflow.com/questions/18037077/c-cli-pin-ptr