最終更新日時:
が更新

履歴 編集

<hive>

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

namespace std {
  template <class InputIterator,
            class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
  hive(InputIterator, InputIterator, Allocator = Allocator())
    -> hive<typename iterator_traits<InputIterator>::value_type, Allocator>; // (1)

  template <class InputIterator,
            class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
  hive(InputIterator, InputIterator, hive_limits, Allocator = Allocator())
    -> hive<typename iterator_traits<InputIterator>::value_type, Allocator>; // (2)

  template <ranges::input_range R,
            class Allocator = allocator<ranges::range_value_t<R>>>
  hive(from_range_t, R&&, Allocator = Allocator())
    -> hive<ranges::range_value_t<R>, Allocator>;                            // (3)

  template <ranges::input_range R,
            class Allocator = allocator<ranges::range_value_t<R>>>
  hive(from_range_t, R&&, hive_limits, Allocator = Allocator())
    -> hive<ranges::range_value_t<R>, Allocator>;                            // (4)
}

概要

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

  • (1) : イテレータ範囲から推論する。
  • (2) : イテレータ範囲と要素ブロックの容量制限から推論する。
  • (3) : Rangeから推論する。
  • (4) : Rangeと要素ブロックの容量制限から推論する。

#include <hive>
#include <vector>
#include <type_traits>

int main()
{
  std::vector<int> v = {1, 2, 3};

  // イテレータ範囲からの推論
  std::hive h1(v.begin(), v.end());
  static_assert(std::is_same_v<decltype(h1), std::hive<int>>);

  // Rangeからの推論
  std::hive h2(std::from_range, v);
  static_assert(std::is_same_v<decltype(h2), std::hive<int>>);
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照