vector and const

后端 未结 10 1719
無奈伤痛
無奈伤痛 2020-12-03 07:13

Consider this

 void f(vector& p)
 {
 }
 int main()
 { 
  vector nonConstVec;
  f(nonConstVec);
 }

The followi

10条回答
  •  情书的邮戳
    2020-12-03 07:58

    vector and vector are unrelated types. The fact that T can be converted to const T doesn't mean a thing here.

    You have to think about it from a type system's standpoint. Instantiated vector doesn't have anything in common with vector.

提交回复
热议问题