As I discussed in my last column, a parameterized type that does more than simple storage and retrieval is constrained as to the acceptable types that may be safely bound to it (see msdn.microsoft.com/msdnmag/issues/05/06/PureC). Using generics, these constraints are made explicit through the where clause. In the C++/CLI template facility, you can often work around these constraints by specializing a function or class template—either individual member functions or an entire class. For the sake of illustration, let's add a min function to my tStack class from the previous column. Ordinarily, I would use the generic min algorithm, but that would only help me as a programmer, not as author of an article on template specialization. For your convenience, the tStack class template definition is reproduced in Figure 1.
展开▼