最終更新日時(UTC):
が更新

履歴 編集

function
<memory>

std::indirect::推論補助(C++26)

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

処理系

関連項目

参照