Let us say that p below has to be a pointer to const X. Then it is not possible to call find for a set of pointers to X with my special compare class. Is that a shortcoming of 'set' and 'find'? Is it safe to solve it with const_cast as I have done?
struct X{
    std::string key;
    X(std::string s): key(s) {}
};
struct compare {
    bool operator() (const X* lhs, const X* rhs) const {
        return lhs->key < rhs->key;
    }
};
int main() {
    std::set<X*,compare> m;
    const X a("hello");
    const X*p=&a;
    std::set<X*,compare>::const_iterator it=m.find(const_cast<X*>(p));
}
 
    