Functions revamp

This patch redesigns the vtables used by `function` and `unique_function`, making them reusable. It also factors their basic shared implementation into a `basic_function`. Finally, it adjusts the interface of `unique_function` to match that of `function` completely, and moves it out of the `detail` namespace.