An instance of std::function has space in itself for containing a limited size of "captured" arguments. to avoid thrashing memory allocations I want to make sure some of the instances of std::function I use do not require an extra allocation for the arguments.
For a specific platform/header is there an easy way to determine what the max size of captures is before it makes a secondary allocation for them ?
From constructor's documentation, emphasize mine:
So, from standard, you have guaranty for function pointer, and
std::reference_wrapper(but no ownership for this one).Else you have to read constructor code of your library/compiler.
For gcc, the condition is (from std_function.h#L124):