Given below is the code(CPP part of it) that I am trying to compile
template<typename... T> void SelectOperation::fetchNextRow(tuple<T...>& row) const { fetchColumn<0, decltype(row), T...>(row, nullptr); } template<int index, typename T, typename U> void SelectOperation::fetchColumn(T& row) const { cout << typeid(row).name(); std::get<index>(row) = this->get<U>(index + 1); } template<int index, typename T, typename U, typename... V> void SelectOperation::fetchColumn(T& row, void*) const { fetchColumn<index, T, U>(row); fetchColumn<index + 1, T, V...>(row, nullptr); //Error at this statement } The errors I am getting are as follows:
D:\workspaces\Calzone_Mayank\modules\Figgy\include\common/db/core/SelectOperation.h(149): error C2783: 'void figgy::SelectOperation::fetchColumn(T &,void *) const': could not deduce template argument for 'U' D:\workspaces\Calzone_Mayank\modules\Figgy\include\common/db/core/SelectOperation.h(58): note: see declaration of 'figgy::SelectOperation::fetchColumn' D:\workspaces\Calzone_Mayank\modules\Figgy\include\common/db/core/SelectOperation.h(149): error C2780: 'void figgy::SelectOperation::fetchColumn(T &) const': expects 1 arguments - 2 provided I am unable to understand why argument for 'U' couldn't be deduced. Why is the compiler unable to determine which overloaded function it should look for?
Edit
The fetchNextRow is called as shown below:
template<typename... T> void SelectOperation::fetchAllRows(vector<tuple<T...>>& rows) const { while (next()) { tuple<T...> row; fetchNextRow<T...>(row); rows.push_back(row); } } AND
vector<tuple<string, string, int>> rows; SelectOperation o("users", {"name", "employee_id", "age"}); o.fetchAllRows<string, string, int>(rows);
fetchNextRow?