I am playing a bit with static polymorphism, I\'m calling a function which internally calls the \"right\" specialized function depending on the type of the initial argument (bas
The call to f_helper(typename T::tag_type{});
is dependent on the template parameter T
, so the name f_helper
need not be visible until the point of instantiation of f
(due to two phase name lookup).
I believe the code works because implementations are allowed to delay the point of instantiation of function templates until the end of the translation unit, at which time the definitions for f_helper
are available.
N3936 §14.6.4.1/8 [temp.point]
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, 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. 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.