// is considered to be unreferenced in the program (unless it is referenced
// elsewhere).
template 
struct FunctionSelector {
    FunctionSelector(T) {}
};
template 
FunctionSelector make_function_selector_true(T fn) {
    return FunctionSelector(fn);
}
template 
FunctionSelector make_function_selector_false(T fn) {
    return FunctionSelector(fn);
}
typedef void(*fn_ptr_type)();
std::vector fns;
template 
void add_fn(FunctionSelector fs) {
    fns.push_back(fs.get());
}
template 
void add_fn(FunctionSelector) {
    // Do nothing.
}
// fn1 will be kept by the linker since it is added to the vector "fns" at
// runtime.
void fn1() {
    printf("fn1\n");
}
// fn2 will be removed by the linker since it isn't referenced at all.
void fn2() {
    printf("fn2\n");
}
int main() {
    add_fn(make_function_selector_true(fn1));
    add_fn(make_function_selector_false(fn2));