Complex C++ Types [message #1489939] |
Thu, 27 November 2014 20:31 |
|
How would I define some more complex C++ types using the C/CPP profile stereotypes?
It's fairly easy for simple things (e.g., pointer), but how can I define, either as class property or as a function parameter, for example
A constant pointer to a constant integer : "int const * const"
A constant pointer to a pointer to an int: "int * * const"
I can only apply each stereotype once to a property/parameter...
I could cheat for properties, e.g., by declaring multiple properties that build on each other - although that is messy. But I can' cheat like that for parameters...
Thanks in advance!
/Charles Rivet
|
|
|
Re: Complex C++ Types [message #1490822 is a reply to message #1489939] |
Fri, 28 November 2014 13:23 |
|
The Ptr stereotype of the C++ profile has an attribute called "declaration". If undefined, it simply corresponds to a star. But you can write "**" in this attribute to obtain a double pointer (and then combine that with the Const stereotype).
You can also write "* const" in the definition part, in this case the result is "const int* const" which is not exactly the same as you wrote (not sure about C++ semantic subtleties in this context).
|
|
|
|
Re: Complex C++ Types [message #1490866 is a reply to message #1490835] |
Fri, 28 November 2014 14:08 |
|
Thanks Ansgar, that's what I needed!
And thank you for updating the wiki page.
BTW, did you know about the "clockwise spiral" method of evaluating C++ declarations?
Using that method, you'll see that "const int* const" is a "constant pointer to an int constant", which is equivalent to what I had in my initial question.
/Charles Rivet
|
|
|
Powered by
FUDForum. Page generated in 0.04582 seconds