why cant I use const arguments in memcpy?

泄露秘密 提交于 2019-12-01 22:11:27

The reason is in the documentation you linked:

double &  operator[] (unsigned int index)
double    operator[] (unsigned int index) const

When you use the non-const version you get a l-value reference and you can take its address (which is the address of the referenced double). When you use the const-version, you get a temporary and the language forbids you to take its address.

Your problem is this here in the documentation:

double  operator[] (unsigned int index) const

The operator[] returns a temporary if you got a const vector. And you can't take the address of a temporary.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!