I was reading about binary trees and I decided I want to create a templated B-Tree class. However, i would like to be able to eliminate the key (more or less - it may still be present, but not necessarily used in the same manner). Instead of using the key to search and insert, I would rather use a user defined function to determine whether an object is greater than or less than another (much like the third parameter in sort()). This part I am somewhat familiar with. What I want to know is, because it seems rather silly to make the user create a function for primitive types, how could I programatically differentiate between primitive types and aggregates? In other words, how could I have it use a pre-defined function when the tree is of type int.

I just thought of something. Perhaps default values for the function pointer parameter is the way to go?
Code:
template<class _T>
class BTree
{
     typedef int KeyBTree;   //The key defined within the Btree class
     KeyBTree insert(const _T &, void * = NULL);
}

PseudoCode
BTree::insert(..., void *p)
{
   if(!p)
       p = DefaultFunction(); //  inline bool DefaultFunction(){return  _T1 < _T2}

  //...........
}

I have yet to try it - I'm too tired to take this on right now.

Perhaps someone else has a batter idea?