Template parameter derived

xiaoxiao2021-03-06  108

Look at the following paragraph: Template struct funcptraits {typedef returnValue_t (* type) (int, int);};

Template void makefuncptr (TypeName Funcptraits :: TYPE ARG1) {// do something};

INT TEST (INT X, INT Y) {RETURN (X Y);

INT main () {makefuncptr (TEST); RETURN 0;}; compiling above with VC.NET will be wrong: C2783, "Declaration": The template parameters of "Identifier" cannot be derived. I want to let the compiler to derive the template parameters of the function template, and must use the template parameters directly in the parameter type declaration of the function, I don't refer to the type definition of the function parameter type used to derive the template parameter should not be used. Nested type definition in a class template. If you indirectly like the above, the compiler that is not smart enough is powerful.

转载请注明原文地址:https://www.9cbs.com/read-101123.html

New Post(0)