Implementing these checks as function objects improves performance slightly (5% or so according to my measurements), probably due to the functions being inlined rather than reduced to function pointers.