vendredi 3 juillet 2020

Why can I std::bind successfully with the wrong parameters?

#include <iostream>
#include <functional>

using callback = std::function<void(int, void*)>;

void AddCallback(callback cb) {}

void foo(int i) {}

int main() {
  auto f = std::bind(&foo, std::placeholders::_1);
  AddCallback(f);
}

I tried the code with g++ 9.3.0 and clang++ 10.0.0, they both compiled ends no errors.

Aucun commentaire:

Enregistrer un commentaire