Udostępnij za pośrednictwem


Deref

Each instance of a Pre or Post attribute specifies a set of properties for the annotated parameter or return value at a particular level of dereference. The level of dereference is specified by the Deref property of the attribute, and all properties appearing after a Deref property are applied to that level of dereference. For example, given a parameter p, an attribute with Deref=0 specifies the properties for p, Deref=1 specifies the properties for *p, Deref=2 specifies the properties for **p, and so on. The value of the Deref should be greater than or equal to 0 and less than or equal to 3.

Note

The default value for this property is 0.

For a parameter of reference type, for example, int& r, Deref=0 applies to the reference itself; Deref=1 applies to the referred-to location, which is - the int in this case.

Example

The following code specifies Deref=1, which applies the Access property to the buffer pointed to by the pointer.

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ( [ SA_Pre ( Deref = 1, Access = SA_ReadWrite ) ] char *p );

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ( [ Pre ( Deref = 1, Access = ReadWrite ) ] char *p );

See Also

Concepts

Annotation Overview