tuple支持CTAD但是还是没有推导模板参数
import <tuple>;import <iostream>;
import <string>;
import<tuple>
using namespace std;
template<typename TupleType, int n>
class TuplePrintHelper
{
public:
TuplePrintHelper(const TupleType& t)
{
TuplePrintHelper<TupleType, n - 1> tp{ t };
cout << get<n - 1>(t) << endl;
}
};
template<typename TupleType>
class TuplePrintHelper<TupleType, 0>
{
public:
TuplePrintHelper(const TupleType&){}
};
template<typename T>
void tuplePrint(const T& t)
{
TuplePrintHelper<T, tuple_size<T>::value> tph{ t };
};
int main()
{
tuple t1{167, "Testaa"s,false, 2.3 };
tuplePrint(t1);
}
tuple不是支持CTAD吗 为什么还是会报无法推导模板参数
页:
[1]