#include #include using namespace std ; /* print any tuple array 2 tuple */ // 1. Base Case: Called when only one argument is left template T print_all(T last) { cout << last << endl; return last; } // 2. Recursive Case: Unpacks the first item and passes the rest forward template void print_all(First first, Rest... rest) { cout << first << ", "; // Recursive call with the remaining parameter pack print_all(rest...); } template decltype(auto) array2tuple_impl( const Array& a, integer_sequence) { return make_tuple(a[I]...); } template> decltype(auto) array2tuple(const array& a) { return array2tuple_impl(a, Indices()); } // Helper to unpack the tuple template void unpack_helper(const Tuple& t, index_sequence object1 ) { print_all( get(t)... ) ; } template void unpack_and_print( const Tuple& tupleObject ) { // Generate indices based on the size of the tuple constexpr auto size = tuple_size_v ; //creates a sort of list of numbers up to the size of the tuple //auto indexSequenceObject1 = make_index_sequence{} ; //index_sequence unpack_helper( tupleObject, make_index_sequence{} ) ; } int main() { std::array arr1 = { 10, 2, 5 } ; auto tupleFromArray = array2tuple( arr1 ) ; cout << get<0>(tupleFromArray) << endl ; cout << get<1>(tupleFromArray) << endl ; cout << "-----" << endl ; unpack_and_print( tupleFromArray ) ; return 0; }