How can a template function 'know' the size of the array given as template argument?

前端 未结 1 595
长发绾君心
长发绾君心 2020-12-19 23:26

In the C++ code below, the templated Check function gives an output that is not what I would like: it\'s 1 instead of 3. I suspect that K is mapped to int*, not

相关标签:
1条回答
  • 2020-12-20 00:22
    template<class T, size_t S> 
    void Check(T (&)[S]) {  
       cout << "Deduced size: " << S << endl;
    }
    
    0 讨论(0)
提交回复
热议问题