Topic: gcc 2.95.2 does not allow explicit template parameters in function declaration of partial specialization.


Author: llewelly@198.dsl.xmission.com
Date: 2000/01/05
Raw View
On 5 Jan 2000, Gabriel Dos Reis wrote:

> llewelly@198.dsl.xmission.com writes:
>
> | [1  <text/plain; US-ASCII (7bit)>]
> | template<typename T0,typename T1>
> |   void foo();
> |
> | template<typename T0>
> |   void foo<T0,int>();

Is it relevant that
template<>
  void foo<int,int>();

compiles fine?

>
> [...]
>
> | function_template_specialization_bug.cc:5: template-id `foo<T0, int>'
> | in declaration of primary template
>
> G++ is right?

If so, how would one declare a partial specialization of
  foo() ?

Could you explain (in more detail) why you think g++ is right?

>
> |
> | Section 14.8.1 paragraph 2 implies that this is allowed.
>
> Really?
>
> 14.8.1/2:
>
>   A template argument list may be specified when referring to a
>   specialization of a template function
>   -- when a function is called,
>   -- when the address of a function is taken, when a function
>      initializes a reference to function, or when a pointer to member
>      function is formed,
>   -- in an explicit specialization,
             ^^^^^^^^^^^^^^^^^^^^^^^

That is the phrase that implied it to me. On the other hand, I cannot find
  any nice convienient statement that says 'a partial specialization is a
  specialization'

In fact, I cannot find any specific statements about function partial
  specializations.

I am cc'ing this to comp.std.c++ to get a second opinion.

I am not cc'ing this to bug-gcc as I think this has become a question
  about the standard.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
Date: 2000/01/05
Raw View
llewelly@198.dsl.xmission.com writes:

| On 5 Jan 2000, Gabriel Dos Reis wrote:
|
| > llewelly@198.dsl.xmission.com writes:
| >
| > | [1  <text/plain; US-ASCII (7bit)>]
| > | template<typename T0,typename T1>
| > |   void foo();
| > |
| > | template<typename T0>
| > |   void foo<T0,int>();
|
| Is it relevant that
| template<>
|   void foo<int,int>();
|
| compiles fine?

Yes.

| >
| > [...]
| >
| > | function_template_specialization_bug.cc:5: template-id `foo<T0, int>'
| > | in declaration of primary template
| >
| > G++ is right?
|
| If so, how would one declare a partial specialization of
|   foo() ?

G++ is right because there is no such thing as 'function template
partial specialization'.  With function template, you can :

 - overload (define another primary template)
 - fully specialize (with explicit template argument. No
          template parameter is permitted).
 - or overload with with a non template function.

| > |
| > | Section 14.8.1 paragraph 2 implies that this is allowed.
| >
| > Really?
| >
| > 14.8.1/2:
| >
| >   A template argument list may be specified when referring to a
| >   specialization of a template function
| >   -- when a function is called,
| >   -- when the address of a function is taken, when a function
| >      initializes a reference to function, or when a pointer to member
| >      function is formed,
| >   -- in an explicit specialization,
|              ^^^^^^^^^^^^^^^^^^^^^^^
|
| That is the phrase that implied it to me. On the other hand, I cannot find
|   any nice convienient statement that says 'a partial specialization is a
|   specialization'

The standard defines precisely what constitutes a 'specialization'
17.7/4:

  [...] A specialization is a class, function, or class member that is
either instanciated or explicitly specialized (17.7.3).

| In fact, I cannot find any specific statements about function partial
|   specializations.

Yes, because the notion of function template partial specialization
does not exist.

Note that partial ordering can bring you the effect of 'partial
specialization'.

-- Gaby
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]