About 35,800 results
Open links in new tab
  1. What is the purpose of std::function and how do I use it?

    Sep 22, 2023 · In general, std::function supports storing any function-like object whose arguments can be converted-from its argument list, and whose return value can be converted-to its return value. It is …

  2. c++ - Explanation of std::function - Stack Overflow

    In most uses that I've seen, std::function was overkill. But it serves two purposes. First, it gives you a uniform syntax for calling function objects. For example, you can use an std::function instantiation to …

  3. Should I copy an std::function or can I always take a reference to it?

    Aug 26, 2013 · Can I store the function as a reference since std::function is just a function-pointer and the 'executable code' of the function is guaranteed to stay in memory? Do I have to make a copy in …

  4. Should I use std::function or a function pointer in C++?

    Use std::function to store arbitrary callable objects. It allows the user to provide whatever context is needed for the callback; a plain function pointer does not.

  5. c++ - How std::function works - Stack Overflow

    Feb 18, 2013 · } My question is around std::function, as you can see it is a template class but it can accept any kind of function signature. For example float (float, float) in this form return_value …

  6. Using generic std::function objects with member functions in one class

    For one class I want to store some function pointers to member functions of the same class in one map storing std::function objects. But I fail right at the beginning with this code: #include <

  7. std::function and std::bind: what are they, and when should they be used?

    Mar 21, 2019 · Notably there are huge differences between a std::function and a lambda, regarding the storage management and regarding the capability of inlining. A binder generated from std::bind is …

  8. c++ - How is std::function implemented? - Stack Overflow

    Jul 21, 2016 · An std::function should have a fixed size, but it must be able to wrap any kind of callables, including any lambdas of the same kind. How is it implemented? If std::function internally uses a …

  9. c++ - std::function vs template - Stack Overflow

    Feb 4, 2013 · std::function and std::bind also offer a natural idiom for enabling functional programming in C++, where functions are treated as objects and get naturally curried and combined to generate …

  10. How to initialize `std::function` with a member-function?

    You cannot directly bind a member-function pointer belonging to type Foo to std::function<void(int)>, specifically because calling a non-static member-function requires an instance of type Foo.