Here, for this function of the template, different instances are generated or not?

Given the following structure and template functions, whether each of them uses a function with a different value for num, creating a new instance of the function, or since the parameter const numbers<num> & numsis a reference and will be implemented as a pointer that everyone uses with different values ​​for "num" can be directed to one function instance?

template<size_t num>    
struct numbers{
 public:
  unsigned int nums[num];
};

template<size_t num>
void print(const numbers<num> & nums,size_t size){
 for (int i=0;i<size;i++)
  cout <<nums.nums[i]<<' ';
 cout <<'\n';
}
+1
source share
3 answers

(), print<2>() print<3>() . , , , . - .

+4

, num.

+3

, .

+1

All Articles