the conversion from a reference to a value looks strange to me
Why?
Does this look strange too?
int foo(int i) { return i; }void bar(const int& ir) { foo(ir); }
This is exactly the same. A function taking an int
by value gets called by another function, taking an int
by const-reference.
Inside bar
the variable ir
gets copied, and the return value gets ignored. That's exactly what happens inside the std::function<void(const int&)>
when it has a target with the signature int(int)
.