#include <iostream>

template<typename T>
struct CRTP_base
{
    void execute()
    {
        static_cast<T*>(this)->f();
    }
};

struct Foo : public CRTP_base<Foo>
{
    void f()
    {
        std::cout << "Wow, compile-time resolved polymorphism!" << std::endl;
    }
};

int main()
{
   Foo my_foo_instance;
   CRTP_base<Foo>& base_reference = my_foo_instance;
   base_reference.execute();
};