1
#include <iostream>
#include <tuple>
#include <type_traits>
template<typename TupleType, typename T, std::size_t index = 0> constexpr std::size_t find_from(){
if constexpr (index == std::tuple_size_v<TupleType>) return index;
if constexpr (std::is_same_v<std::tuple_element_t<index, TupleType>, T>) return index;
return find_from<TupleType, T, index+1>();
}
int main(){
std::cout << find_from<std::tuple<int,double>, int, 0>()<< std::endl;
}
std :: tupleで型のインデックスを検索したいのですが、なぜこのコードをmingw64-gccでコンパイルできないのですか?再帰的なテンプレートが深すぎると私に教えてくれるようです。 std :: tupleで型インデックスを見つける正しい方法は何ですか? gccのバージョン7.2.0、-std = C++ 17std :: tupleでタイプをチェックするC++テンプレート再帰
:おかげで、 –
はそれを得たずさんな説明を変更し、私があれば、時間をコンパイル誤解します –