Alex Rivera | Logout

Why do we use std::function in C++ rather than the original C function pointer?

Asked 2012-07-05T21:38:06.693
47

What is the advantage of std::function<T1(T2)> over the original T1 (*)(T2)?

Edit
Report

1 Answer

17

std::function can hold function objects (including lambdas), as well as function pointers with the correct signature. So it is more versatile.

answered 2012-07-05T21:40:47.010

Your Answer