Topic: Member function template explicit specializations.


Author: wmm@fastdial.net (William M. Miller)
Date: Wed, 28 Mar 2001 12:47:53 CST
Raw View
[posted and mailed]

kavdeiv@mail.ru ("Kiril Avdeiv") wrote in <E14gBpT-000MSk-00@f12.port.ru>:

>I've been reading and rereading the piece 14.7.3/18:
>
>"In an explicit specialization declaration for a member of a class
template or a member template that appears in namespace scope, the member
template and some of its enclosing class templates may remain
unspecialized, except that the declaration shall not explicitly specialize
a class member template if its enclosing class templates are not explicitly
specialized as well. In such explicit specialization declaration, the
keyword template followed by a template-parameter-list shall be provided
instead of the template<> preceding the explicit specialization declaration
of the member...".
>
>For brevity's sake, lets restrict the discussion to cases when there's a
class template with a nested member class template and a member function
template.
>
>While it's clear that you cannot explicitly specialize a member class
template without explicitly specializing the enclosing class, I'm not sure
that the above paragraph renders constructs like the one below semantically
incorrect:
>
>template<class T1>
>class  A  {
>   template<class T2>
>   class  B  {
>   };
>   template<class T2>
>   void  foo(T2 param) {}
>};
>template<class T1> template<>
>void A<T1>::foo(long double param) {}
>
>In fact, I read it as allowing for it.
>
>Can anybody from the the standardization committee elucidate the meaning
of the paragraph please?

That wording is very unclear because there are _two_ (or more)
"template" keywords in such a declaration.  However, the one it
is referring to is the one associated with the nested member, not
with the containing class template.  In your example, it's saying
that the "template<>" you use as the introducer for "foo" must be
a regular template argument list instead.

(If I misunderstood your question, please let me know.)

--
William M. Miller, wmm@fastdial.net

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: kavdeiv@mail.ru (\"Kiril Avdeiv\")
Date: Thu, 22 Mar 2001 21:57:15 GMT
Raw View
I've been reading and rereading the piece 14.7.3/18:

"In an explicit specialization declaration for a member of a class template or a member template that appears in namespace scope, the member template and some of its enclosing class templates may remain unspecialized, except that the declaration shall not explicitly specialize a class member template if its enclosing class templates are not explicitly specialized as well. In such explicit specialization declaration, the keyword template followed by a template-parameter-list shall be provided instead of the template<> preceding the explicit specialization declaration of the member...".

For brevity's sake, lets restrict the discussion to cases when there's a class template with a nested member class template and a member function template.

While it's clear that you cannot explicitly specialize a member class template without explicitly specializing the enclosing class, I'm not sure that the above paragraph renders constructs like the one below semantically incorrect:

template<class T1>
class  A  {
   template<class T2>
   class  B  {
   };
   template<class T2>
   void  foo(T2 param) {}
};
template<class T1> template<>
void A<T1>::foo(long double param) {}

In fact, I read it as allowing for it.

Can anybody from the the standardization committee elucidate the meaning of the paragraph please?

Thank you in advance.

Kiril.



--
Posted from [213.17.96.146] by way of mx7.port.ru [194.67.23.44]
via Mailgate.ORG Server - http://www.Mailgate.ORG

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Victor Bazarov" <vAbazarov@dAnai.com>
Date: Thu, 22 Mar 2001 22:23:49 GMT
Raw View
""Kiril Avdeiv"" <kavdeiv@mail.ru> wrote...
> I've been reading and rereading the piece 14.7.3/18:
>
> "In an explicit specialization declaration for a member of a class
template or a member template that appears in namespace scope, the
member template and some of its enclosing class templates may remain
unspecialized, except that the declaration shall not explicitly
specialize a class member template if its enclosing class templates are
not explicitly specialized as well. In such explicit specialization
declaration, the keyword template followed by a template-parameter-list
shall be provided instead of the template<> preceding the explicit
specialization declaration of the member...".
>
> For brevity's sake, lets restrict the discussion to cases when there's
a class template with a nested member class template and a member
function template.
>
> While it's clear that you cannot explicitly specialize a member class
template without explicitly specializing the enclosing class, I'm not
sure that the above paragraph renders constructs like the one below
semantically incorrect:
>
> template<class T1>
> class  A  {
>    template<class T2>
>    class  B  {
>    };
>    template<class T2>
>    void  foo(T2 param) {}
> };
> template<class T1> template<>
> void A<T1>::foo(long double param) {}
>
> In fact, I read it as allowing for it.
>
> Can anybody from the the standardization committee elucidate the
meaning of the paragraph please?

Right away: I am not from the Committee, I only have one extra
question.

I always thought that when one defined a member template, the
"template<...>" for it was sort of _enclosing_ the outer class
or template.  So, what I learned is that a correct way of
defining the foo specialization would be

    template<> template<class T1>
        void A<T1>::foo(long double param) {}

Is there really any difference?  Or do I simply know it wrong?

Thank you.

Victor
--
Please remove capital A's from my address when replying by mail



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]