以下の内容はhttps://yohhoy.hatenadiary.jp/entry/20260307/p1より取得しました。


型パックからのインデクス指定

プログラミング言語C++において、テンプレートパラメータパック(template parameter pack)からインデクス指定で型(type)を選択する方法。C++2c(C++26)以降では直接的な記述が可能となる。

#include <tuple>

// C++11
template <std::size_t Idx, typename... Ts>
using Selector = typename std::tuple_element<Idx, std::tuple<Ts...>>::type;

// C++14
template <std::size_t Idx, typename... Ts>
using Selector = std::tuple_element_t<Idx, std::tuple<Ts...>>;

// C++2c(C++26)
template <std::size_t Idx, typename... Ts>
using Selector = Ts...[Idx];

// Selector<0, char, int, float> == char
// Selector<1, char, int, float> == int
// Selector<2, char, int, float> == float

関連URL




以上の内容はhttps://yohhoy.hatenadiary.jp/entry/20260307/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14