[Bug c++/18306] seems not possible to specialize a template member function

ramya dot chandar at wipro dot com gcc-bugzilla@gcc.gnu.org
Tue Nov 23 12:31:00 GMT 2004


------- Additional Comments From ramya dot chandar at wipro dot com  2004-11-23 12:31 -------
Subject: Re:  seems not possible to specialize a template member
 function

clarification please...

I tried including "template<>" in front of each of the specialized template member functions. It doesn't solve the problem.

Looking at my code, for my knowledge, it doesn't look like violating the rule (14.7/5). Can you please tell me what exacting is going wrong and how does it violates the rule. 

According to 14.7/5 rule, 
A  non-exported template that is neither explicitly specialized nor explicitly instan-
  tiated must be defined in  every  translation  unit  in  which  it  is implicitly   instantiated or  explicitly  instantiated; no diagnostic is required. An  exported  template need  only  be declared (and not necessarily defined) in a translation unit in which it is instantiated.  A template function  declared  both exported and inline is just inline and not exported.

But, in the code i have attached,( since the generalised and specialized template member functions ) are explicitely instantiated in a module( Sequence.impl ), its not defined separately in any of the translation unit. Still why does it fail.

I don't know how is it violating the rule. Can you please tell me, what needs to be done exactly.

Thanks,
Ramya.

------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-05 04:28 -------
As I said before the code you have here is invalid C++.

you have to add
template<> in front of each of the specialization of a template member function.

Also you have problems with template namelookup also (read the 3.4 release notes for the problems 
which I am talking about).

-- 

pinskia at gcc dot gnu dot org wrote:

>------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-05 05:03 -------
>Invalid, as what you are doing is called explicit specializtion and when this happens you instantiate the 
>template and now you are violating the one defintional rule (which is 14.7/5 in the C++ standard).
>
>  
>




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18306



More information about the Gcc-bugs mailing list