mcostalba wrote:Ok, after some googling I understood this thing is called POI (point of instantiation) and it is when the compiler instantiates the function template. Contrary to popular belief this is not at template calling site, but the rule is _slightly_ more complex:Code: Select all
This is the statement from ISO C++ Standard 14.6.4.1 Point of instantiation [snip] [/quote] BTW, since C++11, the Standard defines in 14.6.4.1 point 8: [quote]A specialization for a function template, a member function template, or of a member function or static data member of a class template may have multiple points of instantiations within a translation unit, [b]and in addition to the points of instantiation described above, for any such specialization that has a point of instantiation within the translation unit, the end of the translation unit is also considered a point of instantiation[/b]. A specialization for a class template has at most one point of instantiation within a translation unit. A specialization for any template may have points of instantiation in multiple translation units. If two different points of instantiation give a template specialization different meanings according to the one definition rule (3.2), the program is ill-formed, no diagnostic required.[/quote] So if you compile with -std=c++11 you should be fine ;-)
C++ puzzle
Moderators: hgm, Rebel, chrisw
-
- Posts: 741
- Joined: Tue May 22, 2007 11:13 am