[Bug c++/21543] Full specialization of templates not supported in classes

sven at clio dot in-berlin dot de gcc-bugzilla@gcc.gnu.org
Sun May 15 14:03:00 GMT 2005


------- Additional Comments From sven at clio dot in-berlin dot de  2005-05-15 14:03 -------
(In reply to comment #3)  
> From 14.7.2 [temp.expl.spec] paragraph 2:  
>   An explicit specialization shall be declared in the namespace of which the  
> template is a member,  
>   or, for member templates, in the namespace of which the enclosing class or  
> enclosing class  
>   template is a member. ...  
  
Well, the standard seems to be inconsistent and You do not have to implement  
all inconsistencies:-( Accept it as a wished extension, please. 
  
After some googling I found some hints to solve this problem at  
http://oopweb.com/CPP/Documents/CPPAnnotations/VolumeFrames.html?/CPP/Documents/CPPAnnotations/Volume/cplusplus16.html  
  
Read and done I get the error messages:  
  
test.cpp:27: error: invalid explicit specialization before '>' token  
test.cpp:27: error: enclosing class templates are not explicitly specialized  
test.cpp:28: error: template parameters not used in partial specialization:  
test.cpp:28: error:         `_T'  
test.cpp:31: error: expected init-declarator before "p"  
test.cpp:31: error: expected `;' before "p"  
  
I know that the enclosing class is not explicitely specialized, that's the  
intention. Is there any compileable example to solve this problem available in  
the net?  
  
And here is the test code:  
  
--- test.cpp  
  
template<typename _T>  
class wrapper  
{  
  public:  
    wrapper(_T t): _M_t(t) {}  
    operator _T& () { return _M_t; }  
  private:  
    _T _M_t;  
};  
  
struct container  
{  
  struct pointer {};  
  struct forward {};  
  struct backward {};  
  struct bidirectional {};  
  struct randomaccess {};  
};  
  
template<typename _T>  
struct heap: container  
{  
  typedef _T value_type;  
  template<typename _U> struct iterator;  
};  
 
// Who invented this syntax? 
template<typename _T> template<>  
struct heap<_T>::iterator <container::pointer>:  
wrapper<typename heap<_T>::value_type *> {}  
  
heap<int>::iterator<heap<int>::pointer> p;  
  
  

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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



More information about the Gcc-bugs mailing list