c++ - Instantiation/Template function specialization -


i'm reading book on c++ , reason can't seem understand template specialization (implicit template instantiation, explicit template instantiation, , explicit specialization) of functions.

to clear, don't understand need explicit template instantiation or explicit specialization when 1 declare/define non-template function, override both generic template function , specialization.

where, when, , why use explicit template instantiation and/or explicit specialization of functions?

one area useful when want overload functions different return type. not supported normal functions there no way compiler resolve ambiguity of 1 variant call. template functions can achieve this

template<typename t>  t func()  {     ... }  template<> std::string func() {     ... }  template<> bool func() {     ... } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -