c++ - Strange "Could not deduce template argument for 'T'" error -
the error in this code:
//myutil.h template <class t, class predicate> t conditionalinput(lpstr inputmessage, lpstr errormessage, predicate condition); //myutil.cpp template <class t, class pred> t conditionalinput(lpstr inputmessage, lpstr errormessage, pred condition) { t input cout<< inputmessage; cin>> input; while(!condition(input)) { cout<< errormessage; cin>> input; } return input; } ... //c_main.cpp int row; row = conditionalinput("input row of number lookup, row > 0: ", "[input error]: specified number not contained in range [row > 0]. " "please type again: ", [](int x){ return x > 0; });
the error is:
error 1 error c2783: 't conditionalinput(lpstr,lpstr,predicate)' : not deduce template argument 't' c_main.cpp 17 1
i've been struggling hours can't seem find solution. believe mistake might trivial, couldn't find else encountering error under similar circumstances. appreciated!
edit: correction made frederik slijkerman fixes 1 issue creates another. time error is:
error 1 error lnk2019: unresolved external symbol "int __cdecl conditionalinput<int,class `anonymous namespace'::<lambda0> >(char *,char *,class `anonymous namespace'::<lambda0>)" (??$conditionalinput@hv<lambda0>@?a0x109237b6@@@@yahpad0v<lambda0>@?a0x109237b6@@@z) referenced in function _main
please bear me , me solve issue.
c++ cannot deduce return type of function. works arguments. have explicitly call conditionalinput<int>(...)
.
Comments
Post a Comment