Why is is it not possible to pass a const set<Derived*> as const set<Base*> to a function?
问题 Before this is marked as duplicate, I'm aware of this question, but in my case we are talking about const containers. I have 2 classes: class Base { }; class Derived : public Base { }; And a function: void register_objects(const std::set<Base*> &objects) {} I would like to invoke this function as: std::set<Derived*> objs; register_objects(objs); The compiler does not accept this. Why not? The set is not modifiable so there is no risk of non-Derived objects being inserted into it. How can I do