I am aware of the following post:
Does C++11 allow vector<const T>?
however I am not able to solve my problem. I am trying to define a vector with a list of const shared_ptr of my class "Example", because these class instances should not be changed.
std::vector<const std::shared_ptr<Example>> myVector;
But when I try to add a const value to the vector, it does not compile:
const std::shared_ptr<Example> example = createMyObject();
myVector.append(example); // compiler error
I am also aware of this post: Non-copyable elements in vector however there is no real answer to my issue. Since my class Example offers several setters, I need to make them const so they cannot be changed.