The following fails to compile with gcc 8.2.0 [stacktrace]
#include <iostream>
#include <tuple>
#include <functional>
void print(int a, int b, int c) {
std::cout << a << ", " << b << ", " << c << std::endl;
}
int main() {
auto b = std::bind(print, 1);
auto t = std::make_tuple(2, 3);
std::apply(b, t);
}
I personally fail to see why, it would seem to be common sense for it to work (in a proper functional language at least).
Could somebody explain the reason it doesn't work?
With std::bind you need to also provide placeholders for the unbound arguments.
auto b = std::bind(print, 1, std::placeholders::_1, std::placeholders::_2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With