Topic: Class template tag declaration and default template arguments
Author: "Sebastian Moleski \(SurakWare\)" <smoleski@surakware.com>
Date: Wed, 24 Jan 2001 18:02:44 GMT Raw View
Hi,
I try to use simple class tag declarations wherever possible to reduce
header-file interdependencies. I mean something like this:
// someheader.h
class Foo; // class tag declaration
class Bar {
private:
Foo *FFoo;
};
This works fine with template as well:
template<class T> class Foo;
class Bar {
private:
Foo<int> *FFoo;
};
Now, I wanted to do the same for the standard list class (std::list), so I
tried this:
namespace std {
template<class T, class A = allocator<A> > class list;
}
However, if I do this, the compiler gives in an error message when it sees
the actual definition of std::list saying that the default argument has been
redeclared. So what should I do? I don't want to use this:
namespaces std {
template<class T, class A> class list;
}
because in that case, I'd have to explicitly specify the allocator wherever
I use the list tag.
So is there any way of declaring a tag name for list? Another approach I
found useful where templatized typedefs (which don't work, of course) like
this:
template<class T> typedef std::list<T, allocator<T> list;
Any help would be appreciated.
sm
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]