Namespaces
Variants

std::polymorphic<T, Allocator>:: operator->, std::polymorphic<T, Allocator>:: operator*

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
constexpr const_pointer operator - > ( ) const noexcept ;
(1) (自 C++26 起)
constexpr pointer operator - > ( ) noexcept ;
(2) (自 C++26 起)
constexpr const T & operator * ( ) const & noexcept ;
(3) (自 C++26 起)
constexpr T & operator * ( ) & noexcept ;
(4) (自 C++26 起)

访问被拥有的值。

1,2) 返回指向被拥有值的指针。
3,4) 返回被持有值的引用。

如果 * this 不包含有效值,则行为未定义。

返回值

如上所述。

注释

此运算符不会检查 * this 是否处于无值状态,用户可通过手动调用 valueless_after_move() 来实现该检查。

示例