Anonymous functions are one of the best features of C++11. They make everything so beautiful! However, one can get carried away and start overusing them.This code calls a function that reads through a file and invokes a callback everytime that something matches a regex. Since I read two different files but I want callbacks only to differ for a constant, I chose this lambda-returning-lambda factory pattern.auto callback_factory =     [&] (IPMarkerType start, IPMarkerType stop) -> std::function<void(IPNode<T>&)>{    return [&,start,stop](IPNode<T> & node){         markers.push_back(IPMarker<T>(node.ip, start));          markers.push_back(IPMarker<T>(node.ip.network_ones(node.prefix), stop));    };};read_regexp<T>(C:\\path\\to\\file1.txt, regex, callback_factory(ipm_a_open,ipm_a_close));read_regexp<T>(C:\\path\\to\\file2.txt, regex, callback_factory(ipm_b_open,ipm_b_close));Callbacks are really local just to the calling function, so I think that external functor would not be justified. On the other hand, this code smells a lot to me, so I would like to hear your comments.
C++11 factory pattern with lambdas
c++;design patterns;c++11;lambda