Udostępnij za pośrednictwem


Valid

The Valid property specifies whether a value satisfies the validity constraints of its type. This property is allowed on Pre and Post attributes and can be used on any data types.

The Valid property must be set using one of the following values:

  • SA_Yes - the value is valid.

  • SA_No - the value is not valid.

  • SA_Maybe - the value might be valid.

The validity constraints for the various built-in types are as follows:

  • Integral and floating-point types – the value has been initialized, that is, it does not contain invalid data.

  • Bool – the value is either True or False.

  • Pointer types – the pointer is either NULL or points to an accessible memory location. The value at the location pointed to by the pointer is not necessarily valid. The validity of that value is determined by the value of the Valid property for the level of dereference one greater than that of the pointer value.

  • Reference types – same as pointer types, except that a reference type cannot be NULL.

Example

The following code shows how to use the Valid property:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Valid=SA_Yes) ] char *pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(Valid=Yes) ] char *pc);

See Also

Concepts

Annotation Overview

Other Resources

Annotation Properties