Fixed building on GCC 4.4.

GCC 4.4 defines std::result_of<T> in <functional> instead of
<type_traits>. Fuck you, GCC 4.4.