    #include <iostream>
    struct CallIntDelegate
    {
        virtual void operator()(int i) const = 0;
    };

    template<typename O, void (O::*func)(int)>
    struct IntCaller : public CallIntDelegate
    {
        IntCaller(O* obj) : object(obj) {}
        void operator()(int i) const
        {
            // This line can easily optimized by the compiler
            // in object->func(i) (= normal function call, not pointer-to-member call)
            // Pointer-to-member calls are slower than regular function calls
            (object->*func)(i);
        }
    private:
        O* object;
    };

    void set(const CallIntDelegate& setValue)
    {
        setValue(42);
    }

    class test
    {
    public:
        void printAnswer(int i)
        {
            std::cout << "The answer is " << 2 * i << "\n";
        }
    };

    int main()
    {
        test obj;
        set(IntCaller<test,&test::printAnswer>(&obj));
    }