Im essayant de créer une fonction de modèle récursif, mais je continue à obtenir l'erreur:déduction/substitution argument modèle VARIADIC a échoué, Méta
no matching function for call to meuPrint(int&, Separator&, string&)
tout en recevant:
candidate: template string meuPrint(U ..., Separator&,string&).
struct Separator {};
template<class ...U>
string meuPrint(U ...b , Separator &placeholder , string& text)
{//end
char buffer[200];
sprintf(buffer , text.c_str() , b...);
return buffer;
}
template<class ...T, class ...U>
string meuPrint(U ...b , Separator &placeholder , string& text , string value , T ...a)
{//string
return meuPrint(b... , to_lower(value) , placeholder , text , a...);
}
template<class V, class ...T, class ...U>
string meuPrint(U ...b , Separator &placeholder , string& text , V value , T ...a)
{//middle
return meuPrint(b... , value , placeholder , text , a...);
}
template<class ...T>
string meuPrint(std::string _text , T ...a)
{//start
Separator placeholder;
return meuPrint(placeholder , _text , a...);
}
int main(int n , char** args)
{
string o = meuPrint( string("hello %i world") , 8);
std::cout << o << std::endl;
return 0;
}
Le but ici n'est pas nécessairement de minuscules les paramètres, mais de tester un concept. Je ne comprends pas pourquoi le compilateur ne parvient pas à déduire tout en me disant quelques candidats valables par la suite.
Voilà pourquoi j'avais cette classe « Separator » entre les variables variadique,. Mais cela ne semble pas résoudre sa pensée. –