c++ - vector of const pointers? -


this question has answer here:

the following doesn't compile (very verbose error, "cannot overloaded" , "invalid conversion 'const void*' 'void*'"). can understand why example push_back() may not compile, can't copy/move foo* const, why doesn't compile:

#include <vector> using namespace std;  class foo;  int main() {   vector<foo* const> vec; } 

the vector container requires elements copy assignable. because elements guaranteed stored contiguously in memory. if exceed capacity, new chunk has allocated , elements re-assigned. cannot const elements.

same error if try std::vector<const int>, or in fact const type.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -