Use functor instead of C++11 lambdas to make it compiler with older g++.