 <p>Here's a more idiomatic and generic approach:</p> <pre><code>template&lt;typename K, typename T&gt; class AVLTree { ... template &lt;typename Comparer&gt; void foo(Comparer cmp) { ... int res = cmp(key1, key2); ... } ... }; </code></pre> <p>Comparer should not be a type that defines a static <code>Compare</code> method. It should be a type which can be called with function call syntax. That allows you to use function pointers of function objects, and it allows you to reuse the comparers already defined in the standard library, or in pretty much any other nontrivial C++ application. It allows you to use lambdas when they're added in C++0x.</p> <p>As for forcing <code>Comparer</code> to behave as expected? The line <code>int res = cmp(key1, key2);</code> already ensures that. If you try to pass a type that can't be called in this way, you get a compile error.</p> <p>The same was the case in your original code. If you passed a type that didn't have a static <code>Compare</code> method, you'd get a compile error. So your original code already solved the problem.</p>