Where to define functors used by many derived classes?
<p>A common scenario in my code is that I got a <strong>functor</strong> that is used by many classes in a hierachy.</p>

<p>To make it accessible by all classes and stay DRY, I usually define it as a protected inner struct of my base class like that:</p>

<pre><code>class Base
{
protected:
    struct CommonFunctor
    {
        bool operator()()
        {
            return true;
        }
    };
};

class DerivedA : public Base
{
    void FooA()
    {
        bool test = CommonFunctor()();
    }
};

class DerivedB : public Base
{
    void FooB()
    {
        bool test = CommonFunctor()();
    }
};
</code></pre>

<p>I don't like that solution because it clutters my base class with many small functors, that are internal only and even if they are not accessible to the public, they decrease readability of my base class.</p>

<p><strong>Do you know any other solutions for this scenario?</strong></p>
