If you had a typedef bool has_f, or a static (something available at compile time), I guess you can branch (using a boost metaprogramming function), or provide 2 templates, one that would instantiate if has_f is defined the other if it's not. It doesn't feel doable directly, without metadata about T, IMHO.