允许所有权根据共享和弱的指针混合比较。如果左侧参数在正确的参数之前按照成员函数 owner_before,返回 true。
template<class Type>
struct owner_less; // not defined
template<class Type>
struct owner_less<shared_ptr<Type> > {
bool operator()(
const shared_ptr<Type>& _Left,
const shared_ptr<Type>& _Right
);
bool operator()(
const shared_ptr<Type>& _Left,
const weak_ptr<Type>& _Right
);
bool operator()(
const weak_ptr<Type>& _Left,
const shared_ptr<Type>& _Right
);
};
template<class Type>
struct owner_less<weak_ptr<Type> >
bool operator()(
const weak_ptr<Type>& _Left,
const weak_ptr<Type>& _Right
);
bool operator()(
const weak_ptr<Type>& _Left,
const shared_ptr<Ty>& _Right
);
bool operator()(
const shared_ptr<Type>& _Left,
const weak_ptr<Type>& _Right
);
};
参数
_left
共享或弱的指针。_Right
共享或弱的指针。
属性值/返回值
如果 _Left 在 _Right 之前按照成员函数 owner_before,返回 true。
备注
模板选件类定义的所有成员运算符成返回 _Left.owner_before(_Right)。
要求
标头: <memory>
命名空间: std