Template Subclassing
Template subclassing is used in SeqAn as a generic alternative for class inheritance.
![]() |
SeqAn uses a special kind of hierarchical structure that we call 'template argument subclassing', which
means that different specializations of a given class template are specified by template arguments. For
example, the array string String<char, Array<100> > is a subclass of String<char>
in the sense that all functions and metafunctions which are
applicable to String<char> can also be applied to String<char, Array<100> > , while it is possible to overload some
functions especially for String<char, Array<100> > . The rules of C++ overload resolution guarantee that the
compiler always applies the most specific variant out of all existing implementations when an algorithm or
trait has been called. This approach resembles class derivation in standard object-oriented programming,
but it is often faster, since it uses static instead of dynamic function binding.
SeqAn - Sequence Analysis Library - www.seqan.de