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

前端 未结 1 596
长发绾君心
长发绾君心 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条回答
  •  旧时难觅i
    2020-12-20 00:22

    template 
    void Check(T (&)[S]) {  
       cout << "Deduced size: " << S << endl;
    }
    

    0 讨论(0)
提交回复
热议问题