Vladimir Nesterovsky wrote:
Although you can easely avoid this restriction I should point out that
gcroot isn't as light as pointers. Its copy involves "GCHandle::Allo c" -
registration of managed pointer handler. The better way is to have gcroot in
some object which is not moved around.
I am well aware that there is a lot more going on behind the scenes when
copying GCHandles than with pointers, and I don't have a performance
problem with it. What I do have a problem with is having to add yet
another wrapper whenever I want a Standard Library container of managed
types. I also don't see how I could prevent such a wrapper object from
being moved around: as soon as it is put into a standard container, it
(and the GCHandle it wraps) *will* be copied. The only way to prevent
this would be to not using standard containers of managed objects in the
first place.
Interestingly, std::sort does not exhibit the described problem.
--
Gerhard Menzl
#dogma int main ()
Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".