Reputation: 35
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
how to solve this problem, i want to CTAD not tuple<int, string_view, bool, double>
i try to update but still not work
Upvotes: 0
Views: 90
Reputation: 4304
Version 17.12.0 Preview 1.0.
New Console project:
To use import,
Upvotes: 0