首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::shared_ptr::operators (>=)

Compare two shared_ptr objects

?

?

template < class T, class U > bool operator==( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(1)

(since C++11)

template< class T, class U > bool operator!=( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(2)

(since C++11)

template< class T, class U > bool operator<( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(3)

(since C++11)

template< class T, class U > bool operator>( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(4)

(since C++11)

template< class T, class U > bool operator<=( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(5)

(since C++11)

template< class T, class U > bool operator>=( const shared_ptr<T>& lhs, const shared_ptr<U>& rhs );

(6)

(since C++11)

Compare a shared_ptr with a null pointer

?

?

template< class T > bool operator==( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(7)

(since C++11)

template< class T > bool operator==( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(8)

(since C++11)

template< class T > bool operator!=( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(9)

(since C++11)

template< class T > bool operator!=( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(10)

(since C++11)

template< class T > bool operator<( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(11)

(since C++11)

template< class T > bool operator<( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(12)

(since C++11)

template< class T > bool operator>( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(13)

(since C++11)

template< class T > bool operator>( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(14)

(since C++11)

template< class T > bool operator<=( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(15)

(since C++11)

template< class T > bool operator<=( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(16)

(since C++11)

template< class T > bool operator>=( const shared_ptr<T>& lhs, std::nullptr_t rhs );

(17)

(since C++11)

template< class T > bool operator>=( std::nullptr_t lhs, const shared_ptr<T>& rhs );

(18)

(since C++11)

比较两shared_ptr<T>对象或比较shared_ptr<T>带空指针。

注意,比较运算符用于shared_ptr简单地比较指针值;指向的实际对象是比较一下。有operator<定义为shared_ptr允许shared_ptr在关联容器中用作键,如std::mapstd::set...

参数

lhs

-

the left-hand shared_ptr to compare

rhs

-

the right-hand shared_ptr to compare

返回值

1%29lhs.get() == rhs.get()

2%29!(lhs == rhs)

3%29std::less<V>()(lhs.get(), rhs.get()),其中V是复合指针类型成std::shared_ptr<T>::element_type*std::shared_ptr<U>::element_type*

4%29rhs < lhs

5%29!(rhs < lhs)

6%29!(lhs < rhs)

7%29!lhs

8%29!rhs

9%29(bool)lhs

10%29(bool)rhs

11%29std::less<std::shared_ptr<T>::element_type*>()(lhs.get(), nullptr)

12%29std::less<std::shared_ptr<T>::element_type*>()(nullptr, rhs.get())

13%29nullptr < lhs

14%29rhs < nullptr

15%29!(nullptr < lhs)

16%29!(rhs < nullptr)

17%29!(lhs < nullptr)

18%29!(nullptr < rhs)

例外

noexcept规格:

noexcept

注记

在所有情况下,它都是存储的指针%28,它是get()%29,它是比较的,而不是托管指针%28--在使用时传递给删除器的指针。[医]计数到零%29。两个指针在共享中可能有所不同。[医]使用别名构造函数创建的PTR。

另见

get

returns the stored pointer (public member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com