我有一组 boost::shared_ptr,我希望它不是通过共享指针而是通过字符串来排序和唯一化的。我是否必须提供一个新的比较函数来获取共享指针并比较内容,或者已经存在我可以使用的比较器?
最佳答案
这非常具体,因此您可能需要一个自定义比较器。
这应该有效:
struct pointercompare
{
bool operator()(const boost::shared_ptr<std::string>& a, const boost::shared_ptr<std::string>& b)
{
return (*a)>(*b);
}
}
关于c++ - boost::shared_ptr<string> 标准集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37918570/