------- Additional Comments From sven at clio dot in-berlin dot de  2005-05-15 
17:58 -------
This is the last try. First I wonder who has invented the strange syntax for 
defining template member classes outside. C++ is still an imperative 
programming language, not a functional. A straightforward syntax would be 
 
template<typename _T> 
struct heap<_T>::template<> 
struct iterator: wrapper<typename heap<_T>::pointer> {}; 
 
But that is not Your concern (unless You are a member of the standardization 
comitee). The errors I get now is: 
 
test.cpp:32: error: aggregate `heap<int>::iterator<container::pointer> p' has 
incomplete type and cannot be defined 
test.cpp:32: error: storage size of `p' isn't known 
 
Simply untrue. 
 
If You replace line 29 with 
 
struct heap<_T>::iterator<container::pointer>: 
 
the errors are 
 
test.cpp:29: error: template parameters not used in partial specialization: 
test.cpp:29: error:         `_T' 
test.cpp:32: error: aggregate `heap<int>::iterator<container::pointer> p' has 
incomplete type and cannot be defined 
test.cpp:32: error: storage size of `p' isn't known 
 
Anyway, the workaround posted earlier is much more comprehensive and easier to 
read. 
 
--- test.cpp 
template<typename _T> 
class wrapper 
{ 
  public: 
    wrapper(): _M_t() {} 
    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; 
}; 
 
template<> template<typename _T> 
struct heap<_T>::iterator<typename heap<_T>::pointer>: // line 29 
wrapper<typename heap<_T>::value_type *> {}; 
 
heap<int>::iterator<heap<int>::pointer> p; 
 
 

-- 


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

Reply via email to