The problem with this setup is that, at least in C ++ 03, you cannot use a local functor as an argument to a template, because it has no external connection. This means that from a technical point of view, the above code is not legal. However, they fix this in C ++ 0x, as these are pretty silly restrictions, and since VS2010 has rudimentary support for C ++ 0x, this code is completely fine.
In short, the answer to your question is that there is nothing wrong with it if you use compilers compatible with C ++ 0x, but otherwise you should probably refrain from this in order to maximize compatibility with multiple compilers.
templatetypedef
source share