C++ local class as functor
<p>I am trying to use a local class as a functor and get compiler error using g++ (3.4.6).</p>

<p>Placing the below class ( <code>Processor</code> ) in the global scope resolves the error, so I guess the error is because of function local structures/classes. I would prefer to have the classes inside the function for code clarity and ease of use. Want to know if there is a workaround solution to make the below code working.</p>

<p><em>test.cpp:24: error: no matching function for call to \u2018foreachArg(int&amp;, char</em>*&amp;, processSubs(int, char*<em>)::Processor&amp;)\u2019</em></p>

<pre><code>template &lt;class Functor&gt;
void foreachArg(int n, char *args[], Functor&amp; f)
{
    for(int i=0; i&lt;n; ++i)
        f(args[i]);
}

int processSubs(int argc, char *args[])
{
    class Processor
    {
        public:
            void operator()(const char *arg)
            {
            }
    };

    Processor p;
    foreachArg(argc, args, p);
}

int main(int argc, char *argv[])
{
    processSubs(argc, argv);
}
</code></pre>
