template 키워드의 다른 또 다른 목적..


14.2.4
When the name of a member template specialization appears after . or ->
in a postfix-expression, or after :: in a qualified-id that explic-
itly depends on a template-argument (_temp.dep_), the member template
name must be prefixed by the keyword template. Otherwise the name is
assumed to name a non-template. [Example:


class X {
public:
    template<size_t> X* alloc();
    template<size_t> static X* adjust();
};

void f(X* p)
{
    X* p1 = p->alloc<200>();
    // ill-formed: < means less than

    X* p2 = p->template alloc<200>();
    // fine: < starts explicit qualification
    T::adjust<100>();
    // ill-formed: < means less than
    T::template adjust<100>();
    // fine: < starts explicit qualification
}


--end example]


[Programming Language C++ (ISO)]

'Dev > C++' 카테고리의 다른 글

GRETA  (0) 2007.05.14
A non-type template-parameter  (0) 2007.05.14
A member template cannot be virtual  (0) 2007.05.14
sgi STL - Why does Bounds Checker™ say that I have memory leaks?  (0) 2007.05.14
MinGW - Why is my C++ binary so large?  (0) 2007.05.14

+ Recent posts