Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

range (C++)

Specifies a range of allowable values for arguments or fields whose values are set at run time.

[ range( 
   low,  
   high 
) ]

low

The low range value.

high

The high range value.

The range C++ attribute has the same functionality as the range MIDL attribute.

// cpp_attr_ref_range.cpp
// compile with: /LD
#include <unknwn.h>
[module(name="MyLib")];

[object, uuid("9E66A290-4365-11D2-A997-00C04FA37DDB")]
__interface ICustom {
   HRESULT Custom([in] long l, [out, retval] long *pLong);
   HRESULT length_is1([in, range(0, 999)] long f, [in, length_is(f)] char array[10]);
   HRESULT length_is2([in, range(-99, -1)] long f, [in, length_is("f"), size_is(10)] char *array);
};

Attribute Context

Applies to

Interface method, interface parameter

Repeatable

No

Required attributes

None

Invalid attributes

None

For more information about the attribute contexts, see Attribute Contexts.

Community Additions

ADD
Show:
© 2015 Microsoft