Why is additional qualification for inline member function definitions prohibited?

If we consider the grammar of a member declaration, it looks like this:

member-declaration:
       function-definition;

function-definition:
       attribute-specifier-seqopt decl-specifier-seqopt declarator 
       virt-specifier-seqopt function-body

declarator:
       noptr-declarator parameters-and-qualifiers trailing-return-type

This disallows the syntax:

struct B {
    A B::*B::read();
};

      

Why doesn't it allow optional nested-name-specifier ::

before the function name?

+3


source to share


1 answer


The grammar does not generally prohibit declaring objects named by nested BOM names. In fact, ads friend

should have:

class A
{
     friend void OtherNamespace::foo();
};

      

This is a member declaration with a declaration specifier friend

. It covered (bold emphasis mine):

member-declaration: attribute-specifier-seq opt decl-specifier-seq opt member-declarator-list opt;

and



member-declarator:     declarator virt-specifier-seq opt pure-specifier opt

The declarator now has the following grammar:

descriptor:
     PTR descriptor

PTR descriptor:
     noptr descriptor

noptr-handle:
     a handle-ID

descriptor-id:
     ...

opt id-expression

Finally, the id expression

id-expression:     qualified identifier

+4


source







All Articles