In trying to understand the cirumstances under which std::bind
allocates memory, I looked at this answer, which gives some intuition, but I wanted a more detailed understanding, so I went and looked at the source for gcc
.
I am examining the following source code for std::bind
from the gcc implementation of the C++ standard library.
/**
* @brief Function template for std::bind.
* @ingroup binders
*/
template<typename _Func, typename... _BoundArgs>
inline typename
_Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
bind(_Func&& __f, _BoundArgs&&... __args)
{
typedef _Bind_helper<false, _Func, _BoundArgs...> __helper_type;
typedef typename __helper_type::__maybe_type __maybe_type;
typedef typename __helper_type::type __result_type;
return __result_type(__maybe_type::__do_wrap(std::forward<_Func>(__f)),
std::forward<_BoundArgs>(__args)...);
}
Given a function F and parameters A and B, where can I find the code that copies them into the returned data structure, or is this compiler generated?