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

来自cppreference.com
< cpp‎ | memory‎ | indirect
 
 
内存管理库
(仅用于阐述*)
分配器
未初始化内存算法
受约束的未初始化内存算法
内存资源
未初始化存储 (C++20 前)
(C++17 弃用)
(C++17 弃用)

垃圾收集器支持 (C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(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 起)
constexpr const T&& operator*() const&& noexcept;
(5) (C++26 起)
constexpr T&& operator*() && noexcept;
(6) (C++26 起)

访问拥有的值。

1,2) 返回指向拥有的值的指针。
3-6) 返回到拥有的值的引用。

如果 *this 无值,那么行为未定义。

返回值

1,2) p
3,4) *p
5,6) std::move(*p )

注解

此运算符不检查 *this 是否无值,用户可以手动用 valueless_after_move() 做检查。

示例