質問

According to this page: http://womble.decadent.org.uk/c++/template-faq.html#non-dependent "Non-dependent names are those names that are considered not to depend upon the template parameters, plus the name of the template itself and names declared within it (members, friends and local variables)"

This appears to be backed up by the fact that the following code is considered valid (by LLVM/Comeau)

template<typename T>
struct Template
{
    typedef int I;
    typedef Template::I Type; // 'Template' is NOT dependent
    typedef Template<T>::I Type2; // 'Template<T>' is NOT dependent
    Template<T>* m;
    void f()
    {
        m->f(); // 'm' is NOT dependent
    }
};

After spending some time reading the C++ 98 standard, I cannot find where this behaviour is specified. I would expect to find a mention of this under 'temp.nondep'.

役に立ちましたか?

解決

The C++98 standard does not define what is exactly meant by "non-dependent", "nondependent" or "not dependent" names (you can find all three forms in standard texts).

Instead it chooses to define what names and types are dependent on template arguments in 14.6 [temp.res] and its sub-chapters. Simple logic applied ... everything that is not said to be dependent is non-dependent. Only reading 14.6.3 [temp.nondep] does not help.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top