C++: combine const with template arguments

后端 未结 6 1500
清酒与你
清酒与你 2020-12-18 11:46

The following example is working when I manualy replace T wirh char *, but why is not working as it is:

template          


        
6条回答
  •  再見小時候
    2020-12-18 12:43

    I guess it's because your function expects const (char *) (since T is char *), i.e. you can't change the address it points to, while const char * stands for (const char) *, i.e. you can't change the value on the place the pointer points to.

提交回复
热议问题