c++ - Force instantiation of friend functions -


assume have template class friend function:

template<class t> class {     friend operator+ (int, const a&); }; 

this function implemented somewhere below:

template<class t> a<t> operator+ (int i, const a<t>& a) {     ... } 

and there force instantiation of class template further below:

template class a<int>; 

does imply operator+(int, a<int>) compiled? or have force instantiate separately achieve that?

template parameters aren't automatically forwarded friend declarations. need specify template parameter function well:

template<class t> class {     template<class u>     friend a<u> operator+ (int, const a<u>&); }; 

implementation correct, should be

template<class t> a<t> operator+ (int i, const a<t>& a) {                            // ^^^     // ... } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -