Overloading class templates on number of parameters
In C++ Templates the Complete Guide by Vandevoorde and Josuttis,
section 13.12 talks about a possible future enhancement of overloaded a
class template based on the number of template parameters. Their
example was a tuple.
I recently came across a place where this concept would apply in my
code.
I have an intermediary class where I would like to say
template < class A >
Intermediate : public A {};
template < class A, class B >
Intermediate : public A, public B {};
tempate < class A, class B, class C >
Intermediate : public A, public B, public C {};
etc.
Instead, I need to say
struct nulltypeB {};
struct nulltypeC {};
template < class A, class B = nulltypeB, class C = nulltypeC >
Intermediate : public A, public B, public C {};
this is similar to how boost::tuple works in implementing "variable"
template parameters
maybe having the extra base classes in a single parameter instance
isn't an issue, I don't know... It adds extra space overhead to the
class (the EBO isn't applied in every case in practice). What is the
status of this, will this be a change in C++ 0x?
Eric
---
[ 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.comeaucomputing.com/csc/faq.html ]