template <class Value>
indirect(Value) -> indirect<Value>; // (1)
template <class Allocator, class Value>
indirect(allocator_arg_t, Allocator, Value)
-> indirect<Value,
typename allocator_traits<Allocator>::template rebind_alloc<Value>>; // (2)
概要
std::indirectクラステンプレートの型推論を補助する。
- (1) : 単一の値から
indirectを構築する場合、その値の型をTとして推論する。 - (2) : アロケータと値から構築する場合、値の型を
Tとし、アロケータをValue向けにrebindした型をAllocatorとして推論する。
例
#include <memory>
#include <type_traits>
int main()
{
std::indirect a{42};
static_assert(std::is_same_v<decltype(a), std::indirect<int>>);
}
出力
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ✅
- Visual C++: 2026 Update 2 ❌