c++ - Confused about implicit template instantiation -


this statement c++03 standard, §14.7.1p5:

if overload resolution process can determine correct function call without instantiating class template definition, unspecified whether instantiation takes place. [example:

template <class t> struct s {        operator int(); };  void f(int); void f(s<int>&); void f(s<float>);  void g(s<int>& sr) {         f(sr);     // instantiation of s<int> allowed not required                    // instantiation of s<float> allowed not required }; 

end example]

i unable understand point. have undefined behavior?

i found similar problem, don't understand. there explained correct behavior undefined, mean?

here: msvc: implicit template instantiation, though templated constructor not used

during overload resolution determined correct function call when write f(sr) void f(s<int>&); without explicitly instantiating definition of class template s, unspecified whether class instantiated.

undefined behaviour , unspecified behaviour 2 different things.

instantiation of s< int > allowed not required

for example:

template <class t =int>  struct s  {   operator int(); }; 

is allowed not required.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -