Saturday, May 14, 2005

17. What does TPtr::operator=() do?

The assignment operator, operator=(), defined for modifiable pointers only, copies data into the memory already referenced by the pointer.

If the length of the data to be copied exceeds the length available, the assignment will panic. TPtr also has a Set() method to change the descriptor to point at different data and you should be careful not to confuse them.

To reiterate:
As I described in 16. What does TPtrC::Set() do?, TPtr::Set() resets either a constant or modifiable pointer descriptor to point at a new data area (with corresponding changes to the length and maximum length members).

The assignment operator on TPtr copies data into the existing descriptor area if it is large enough, or panics if it is not. It may modify the descriptor length but will not affect its maximum length.

This page is powered by Blogger. Isn't yours?

Google
WWW Descriptors FAQ