c++ - 容器元素是const元素时的错误
PHP中文网
PHP中文网 2017-04-17 13:12:23
0
2
745

"The C++ Standard forbids containers of const elements "
"because allocator<const T> is ill-formed."

这个ill-formed是什么意思?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦

I don’t know what container you are using, if it is a vector, because when the vector adds elements, if there is not enough space, it will reallocate more memory, and copy the original vector elements and reassign them to the new vector. If the element type is const, reassignment is not supported. So the compiler will report an error

刘奇

Ill means pathological, bad and undesirable. Ill formed is the wrong form.
How do you modify const T when it is new... The standard library container does not support const T because it cannot be modified. , you need to copy your elements like vector.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!