- memory[meta header]
- std[meta namespace]
- indirect[meta class]
- function[meta id-type]
- cpp26[meta cpp]
constexpr const T& operator*() const & noexcept; // (1)
constexpr T& operator*() & noexcept; // (2)
constexpr const T&& operator*() const && noexcept; // (3)
constexpr T&& operator*() && noexcept; // (4)所有するオブジェクトへの参照を取得する。constなアクセス経路ではconstが所有オブジェクトに伝播する。
*thisが無効値状態でないこと。
- (1), (2) : 所有するオブジェクトへの参照。
- (3), (4) : 所有するオブジェクトへの右辺値参照(
std::move(*p))。
投げない。
#include <cassert>
#include <memory>
#include <type_traits>
int main()
{
std::indirect<int> a{42};
assert(*a == 42); // 参照の取得
*a = 10; // 非const版で書き換え
assert(*a == 10);
// constなアクセス経路ではconstが伝播する
const std::indirect<int> b{5};
static_assert(std::is_same_v<decltype(*b), const int&>);
}- std::indirect[link ../indirect.md]
- C++26
- Clang: 22 [mark noimpl]
- GCC: 16.1 [mark verified]
- Visual C++: 2026 Update 2 [mark noimpl]