c++ - Template instanciation errors, MSVC vs GCC -
OK I found the following template (which has a big error):
template < Class FluxVar = IloIntVar, Class FluxVarArray = IloIntVarArray, Class DelayVar = IloIntVar, Class DelayVarArray = IloIntVarArray, Class LoadVar = IloIntVar, Class LoadViraRaire = IloIntVarArray, Class BoolVar = IloBoolVar, Class BoolVarArray = IloBoolVarArray & gt; Classroom Myllic {public: int getAlpha () {return m_alpha; } Private: int m_alpha1; // "1" see here}
In my code, I do something like this:
MyClass & lt; & Gt; MyClass1; MyClass & lt; IloNumVar, IloNumVarArray, IloNumVar, IloNumVarArray, IloNumVar, IloNumVarArray & gt; MyClass2; MyClass & lt; IloNumVar, IloNumVarArray, IloNumVar, IloNumVarArray, IloNumVar, IloNumVarArray, IloNumVar, IloNumVarArray & gt; MyClass3; / * Some items with my class, but never call coded with MSVC, call myClassX.getAlpha () * /
, but with GCC, (of course) saying Is:
MyClass.h: 109: 39: error: m_alpha was not declared in this area
So my questions are: about this What is the standard? Is it adaptable to MSVC and if so, what has been optimized in this case?
I do not think the MSVC code generates getAlpha
because it is never called, but as usual MSVC thinks this is not a standard behavior .
As far as I know MSVC is not always compliant, as an extension, Membership within the class allows expertise for functions.
The MSVC code is not clear, if you use a member of that function, this will trigger an error, even if you explicitly instruct it or explicitly:
template & lt; Typename T & gt; Classes Mylals {public: int mill alpha () {return m_lofa 32; } Private: int m_alpha1; // see "1" here}; The template's & lt; & Gt; Classy Myclass & lt; Int & gt; {// Special Specialization makes the error public: int getAlpha () {return m_alpha32; } Private: int m_alpha1; // see "1" here}; Template category MyClass & lt; Int>; // clarification instant, error int main () {MyClass & lt; Int & gt; Obj; // does not trigger the single error obj.getAlpha (); // error return 0 triggers; }
Take a look here:
The compiler generates code for a template class or function when the class or function is turned on. When a member is called a function, an instant encounter occurs, and the virtual member's function is instant when its orbit is formed. This problem can arise if you are creating a library with templates for other users.
and
A class template is specific first and then by its immediate compiler.
Thus no diagnostic is required or the code is not being generated at all.
Comments
Post a Comment