Q:

C++ Template: typename and function to map to int

I'm writing a C++ template that needs two params: typename T, and an arbitrary function that maps T to an unsigned int.
How can I declare and use a template that can do that? I'd like to keep it simple, so that any dumb function can be used.
UPDATE:
Here is an example of what I'd like to do:
 template<typename T, function f> // f has signature: unsigned int f(T);
 class SortedContainer {
      ...
 }

And, in this file:
 unsigned int weight(Package p) { return p.w; }

 SortedContainer<Package, &weight> sc;

UPDATE upon writing code
Based on the answers, I tried writing code, but it won't compile.  Or rather, the template will compile, but not the test which invokes it.
The template code looks like this:
template<typename T, typename f>
class C {
...f(T)...
...

The invocation code looks like:
struct S {
int operator()(const int n) {
    return n; // Dummy test code
}
 };

 ...C<int, S>&...

The error message is:
 error: no matching function for call to 'S::S(const int&)'
 note: candidates are:
 note: S::S()

It seems like it's trying to use S's constructor for some reason, as opposed to using the operator() which I want it to do.
The purpose of the f parameter is that the SortedContainer needs to be able to position T by an integer value.  T is not necessarily an integer or even Comparable, so the caller, when instantiating a SortedContainer, needs to pass not only type T, but a function f to transform T to an integer.

A:

IMO, you don't require a separate template argument for Function F. 
template<typename T>  // F not required!
class SortedContainer {
      ...
};

Choose a good name and use that function by overloading it for various cases. e.g. to_uint()
Since you want to map (i.e. relate) a type to an unsigned int (uint), use following function in global scope:
template<typename T>
uint to_uint (const T& t) {
  return t.to_uint();  // Must have `uint to_uint() const` member, else error
}

// Overloads of `to_uint()` for PODs (if needed) 

template<typename T>  // For all kinds of pointers
uint to_uint (const T* const pT) {
  if(pT == nullptr)
    <error handling>;
  return to_uint(*pT);
}

Scenario: For Sorted_Container<X>, whenever to_uint(x) is invoked, then:

If X is a class, then it must have uint to_uint() const method
Else if X is a POD, then you may have to overload to_uint() for that type
Else, the compiler will generate an error

