|
That’s not correct - you can template and specialize on values. What you can’t do is have a value whose type depends on another templated type, but an inner class can get around this. There is an alternative but non-standard way i’ve used in the past, but if I had to do this kind of integration with Lua again I’d rather have C style functions with an explicit self. Hopefully this demonstrates - but please don’t mistake for useful or pretty code :) #include <string> #include <iostream> struct C { double b (std::string a) { return 2.5; } }; template<typename C, typename G, typename F> struct Wrapper { public: typedef G (C::*M) (F); template<M m> struct Inner { G operator() (C& r, F f) { return ((&r)->*m) (f); } }; }; Wrapper<C, double, std::string>::Inner<&C::b> w; … double res = w (c, "A”); |