#include <type_traits>
#include <string>

template <typename Heir>
class SToString {
public:
    std::string toString() {
        return static_cast<Heir*>(this)->toStringImpl();
    }
};

class Foo : public SToString<Foo> {
public:
    std::string toStringImplRRRRRRRRRRRRR() {
        return "Foo";
    }
};

int main() {
	Foo f;
	
	f.toString();
	
	return 0;
}