My code looks like this:
template<typename F>
void printHello(F f)
{
f("Hello!");
}
int main() {
std::string buf;
printHello([&buf](const char*msg) { buf += msg; });
printHello([&buf]() { });
}
The question is - how can I restrict the F
type to accept only lambdas that have a signature void(const char*)
, so that the second call to printHello
doesn't fail at some obscure place inside printHello
but instead on the line that calls printHello
incorrectly?
Aucun commentaire:
Enregistrer un commentaire