C
Chris Jefferson
Now, C++ doesn't actually provide true variable-length templated
classes, for example you can't do (as I found recently!)
template<class T>
class tuple { ... }
template<class T, class U>
class tuple { ... }
There appear to be two main ways of "faking" this.
In "modern C++ design", a system of encoding lists of types as a single
type is used. However I much perfer the "default arguments" methods, like:
template<class T=EmptyClass, class U=EmptyClass>
class tuple;
template<class T>
class tuple<T,EmptyClass>
{ (implement length 1 here) }
....
As it looks much more natural to the user. Is there some reason that
encoding types as a typelist is better?
Chris
classes, for example you can't do (as I found recently!)
template<class T>
class tuple { ... }
template<class T, class U>
class tuple { ... }
There appear to be two main ways of "faking" this.
In "modern C++ design", a system of encoding lists of types as a single
type is used. However I much perfer the "default arguments" methods, like:
template<class T=EmptyClass, class U=EmptyClass>
class tuple;
template<class T>
class tuple<T,EmptyClass>
{ (implement length 1 here) }
....
As it looks much more natural to the user. Is there some reason that
encoding types as a typelist is better?
Chris