jeudi 29 septembre 2016

C++ Variadic template - Unable to figure out the compilation error

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);
}

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?

Aucun commentaire:

Enregistrer un commentaire