I could be mistaken, though I believe that the STL sorted containers expect a type with a valid operator<. If the type doesn't provide one, then overloaded constructor(s) will take an additional parameter in the form of a compare function, or a function object which overloads operator() instead.
Since you don't know the precise type of the comparator in advance, you need to provide a templated constructor where any kind of comparator can be used to compare objects within the data structure
Here's a brief example of a constructor accepting a functor, whose type is determined at compile time.
/* less_comparator - user-defined comparison */
template <typename T>
struct less_comparator
{
bool operator()(T, T) const;
};
template <typename T>
bool less_comparator<T>::operator() (T lhs, T rhs) const
{
return lhs < rhs;
}
template<typename T>
class structure
{
public:
structure() {}
template<class Comparator>
structure( Comparator comp )
{
}
};
int main()
{
structure<int> s( less_comparator<int> );
}