import <tuple>;
import <iostream>;
import <string>;
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 }; //this lines show all err
tuplePrint(t1);
}
visual studio2022 run show
C2641 tuple couldn’t deduce std::tuple template parameter , this shows tuple supports CTAD so what is the problem how to solve this problem
C2780 “std::tuple<_Types…> std::tuple(void)”: should input 0 parameter,but Provided 4 parameters
C2780 “std::tuple<_Types…> std::tuple(std::tuple<_Types…>)”: should input 1 parameter,but Provided 4
i learn from
https://github.com/carlesmartin85/procpp5e/blob/65aedda6a92745beca48a5041411465a33cdf4cd/code/c26_code/16_PrintTuple/02_PrintTupleSimplified.cpp
how to solve this problem, i want to CTAD not tuple<int, string_view, bool, double>
9