C ++ unfamiliar use of ':' in declaration

I find it difficult to understand some existing code in order to update it. I am not familiar with the use of colons and the program name in this declaration. The program is called rbac4xml, which appears to be called in the declaration, and then the colons are used to access the type and pointer of the Role.

void output_keyrings(const std::vector<rbacp4xml:Role:*> &roles, const rbacp4xml::Keys &keys ); 

I tried to find this in directories and Google, but now, unfortunately, I have to ask :) Thanks for any help.

+4
source share
2 answers

Ad

 const rbacp4xml::Keys &keys 

makes it clear that rbacp4xml is a class that has a member type called Keys.

Ad

 const std::vector<rbacp4xml:Role:*> &roles 
As far as I know,

not valid C ++. Since #defines do not allow colons inside, you can be sure that rbacp4xml: Role: has not been redefined in this way. Even if you define a role as an empty definition, i.e.

 #define Role 

you are not allowed to write rbacp4xml: Role: get rbacp4xml ::.

Therefore, I strongly suspect that this is a spelling mistake. He should probably read:

 const std::vector<rbacp4xml::Role *> &roles 

This means that you are creating a vector of pointers, each of which points to a variable of type rbacp4xml :: Role, i.e. in the rbacp4xml class there is a typedef role.

If your code compiles, perhaps this part is somehow bypassed. Try putting #error before the declaration. If your code is still compiling, you will realize that it bypasses. It may be skipped if you put in #ifdef .. # endif, for example.

+2
source

This is invalid portable C ++. Maybe this is a user extension, or this code is run through some preprocessor before being sent to the C ++ compiler.

0
source

Source: https://habr.com/ru/post/1501217/


All Articles