The following doesn't compile (very verbose error, but basically "cannot be overloaded" and "invalid conversion from 'const void*' to 'void*'"). I can understand why for example push_back() may not compile, as you can't copy/move into a Foo* const
, but why doesn't this compile:
#include <vector>
using namespace std;
class Foo;
int main()
{
vector<Foo* const> vec;
}
You are declaring a vector that contain const
pointer of Foo, that mean that the pointer could not be modified. When you insert an element in the vector would need to write to a const pointer
(not valid).
You are sure it's not: std::vector<Foo const *> vec;
where Foo don't be modified by the pointer could.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With