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

履歴 編集

<scoped_allocator>

std::scoped_allocator_adaptor::推論補助(C++17)

namespace std {
  template <class OuterAlloc, class... InnerAllocs>
  scoped_allocator_adaptor(OuterAlloc, InnerAllocs...)
    -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
}

概要

std::scoped_allocator_adaptorクラステンプレートの型推論補助。

このクラスのコンストラクタは、クラステンプレートパラメータの型に変換可能なアロケータを受け取る。変換コンストラクタのパラメータ型からクラステンプレートパラメータを推論させるようになっている。

#include <memory>
#include <scoped_allocator>
#include <string>
#include <vector>

int main()
{
  std::scoped_allocator_adaptor scoped_alloc {
    std::allocator<std::string>{},
    std::allocator<char>{}
  };

  std::vector v {3, std::string("hello"), scoped_alloc};
}

出力

バージョン

言語

  • C++17

処理系

関連項目

参照