Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of a double dot within a square bracket in C++

Tags:

c++

windows

c++11

In the file C:\Program Files (x86)\Windows Kits\8.1\Include\um\OleAuto.h, I found the following code that I do not know how to interpret:

WINOLEAUTAPI SafeArrayAccessData(_In_ SAFEARRAY * psa,
_Outptr_result_buffer_(_Inexpressible_(psa->cbElements * 
product(psa->rgsabound[0..psa->cDims-1]->cElements))) 
void HUGEP** ppvData);

Note the double period within the square bracket. Is that a new operator in C++?

like image 297
Hector Avatar asked Jun 04 '15 18:06

Hector


People also ask

What does the double dot symbol mean?

: two points placed immediately after a musical note or rest to indicate augmentation of its time value by three-quarters.

What does the DOT do in C?

The dot (.) operator is used for direct member selection via object name. In other words, it is used to access the child object.

What does double dot mean in C++?

The two dots (a colon) are followed by what's called an initializer list.

What is double dot in Rust?

Two periods ( .. ) is the range operator. You can find this in the Operators and Symbols Appendix of the Rust book. There are six flavors: Range : 1..


1 Answers

It appears to be a SAL annotation used to tell the static analyzer that the size of the buffer is too complex to represent using ordinary annotations:

https://msdn.microsoft.com/en-us/library/jj159527.aspx

It doesn't have to contain valid syntax, but what it contains is probably meant to succinctly illustrate to a human reader how the size of the buffer could be calculated.

If I'm to interpret it myself, I'd guess it means what the following code would yield:

DWORD CalculateInexpressibleSafeArrayDataSize(SAFEARRAY * psa)
{
    DWORD cbSize = psa->cbElements;
    for (int i = 0; i < psa->cDims; i++) // product()
        cbSize *= psa->rgsabound[i]->cElements;
    return cbSize;
}
like image 53
DoomMuffins Avatar answered Sep 20 '22 00:09

DoomMuffins