This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21543] Full specialization of templates not supported in classes
- From: "sven at clio dot in-berlin dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 May 2005 14:43:22 -0000
- Subject: [Bug c++/21543] Full specialization of templates not supported in classes
- References: <20050513094441.21543.sven@clio.in-berlin.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From sven at clio dot in-berlin dot de 2005-05-15 14:43 -------
And for everyone who have the same problem, here is a workaround. Declare a
template class with a dummy argument (int in this case), partial specialize
this class and derive from the partial specialized template class. Why?
Because the standard says so, there is no other reason (in other words, there
is no reason at all).
--- 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, int _i> struct _iterator;
private:
// the absolute unnecessary additional template class
template<int _i>
// partial specialization is allowed
struct _iterator<pointer, _i>: wrapper<value_type *> {};
public:
template<typename _U> struct iterator: _iterator<_U, 0> {};
};
heap<int>::iterator<heap<int>::pointer> p;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21543