<p>At my workplace, we tend to use  <strong>iostream</strong>, <strong>string</strong>, <strong>vector</strong>, <strong>map</strong>, and the odd <strong>algorithm</strong> or two.  We haven't actually found many situations where template techniques were a best solution to a problem.</p>

<p>What I am looking for here are ideas, and optionally sample code that shows how you used a template technique to create a new solution to a problem that you encountered in real life.</p>

<p>As a bribe, expect an up vote for your answer.</p>

General info on templates:
Templates are useful anytime you need to use the same code but operating on different data types, where the types are known at compile time.   And also when you have any kind of container object.
A very common usage is for just about every type of data structure.  For example: Singly linked lists, doubly linked lists, trees, tries, hashtables, ...
Another very common usage is for sorting algorithms.
One of the main advantages of using templates is that you can remove code duplication.  Code duplication is one of the biggest things you should avoid when programming.
You could implement a function Max as both a macro or a template, but the template implementation would be type safe and therefore better.
And now onto the cool stuff:
Also see
template metaprogramming
, which is a way of pre-evaluating code at compile-time rather than at run-time.  Template metaprogramming has only immutable variables, and therefore its variables cannot change.  Because of this template metaprogramming can be seen as a type of functional programming.
Check out this example of template metaprogramming from Wikipedia.  It shows how templates can be used to
execute code at compile time
.  Therefore at runtime you have a pre-calculated constant.
```
```
template <int N>
struct Factorial 
{
    enum { value = N * Factorial<N - 1>::value };
};

template <>
struct Factorial<0> 
{
    enum { value = 1 };
};

// Factorial<4>::value == 24
// Factorial<0>::value == 1
void foo()
{
    int x = Factorial<4>::value; // == 24
    int y = Factorial<0>::value; // == 1
}
```
```