c++ - Potential evaluation of inline function bodies and instatiation of template members -
Where are expressions inside an inline marked function marked as 'probability evaluation'?
a.cpp
template & lt; Typename T & gt; CONST T & amp; Foo (Constt and Edge) {Return AGR; } Inline void () {int x (21); X = foo (x); }
b.cpp
#include & lt; Iostream & gt; Template & lt; Typename T & gt; CONST T & amp; Fu (Consta & amp; amp;); Int main (int argc, char * argv []) {std :: cout & lt; & Lt; Fu (12) & lt; & Lt; Std :: endl; }
If the inline function is defined, the expression is considered 'probable evaluation', then the template should be done immediately, and I hope that the $ (CCC) -ca CPP; $ (Ccc) - cbpp; To successfully link $ (CCC) ao bo -o bin
, if the expression within a function declared function becomes only 'potential evaluation', when such a function is automatically used, then I Hopefully $ (CCC) -c a.cpp; $ (Ccc) - cbpp; $ (CCC) AO BO-O Bin
to fail during the link phase.
So far I have tested all versions of XL C ++ 12 (which successfully links), and GCC + 3 horn 3.5 (all of which failed to link).
Which behavior is right? Am I missing a third option here?
§14 [temporary] / p6:
a function template , Member templates of class templates, variable templates, or static data members of the class templates will be defined in each translation unit, in which it is inherently immediate (14.7.1) unless there is a specific expertise in some translation unit clearly Immediately from (14.7.2); There is no diagnostic requirement.
Your diagnosis is necessary for your diagnosis without diagnosis. Both compilers are behaving correctly.
Comments
Post a Comment