3 ms·
std::mem_fn will effectively give you the underlying function that takes a pointer. Strictly speaking mem_fn is defined to generate the wrapper function, but in
by kllrnohj 4y ago
std::mem_fn will effectively give you the underlying function that takes a pointer. Strictly speaking mem_fn is defined to generate the wrapper function, but in practice the optimizer is just going to strip that away and call the name-mangled function directly.
Example: https://godbolt.org/z/6Y1raxMce https://godbolt.org/z/6Y1raxMce
- Matheus28 4y agoYou can just use member function pointers without the wrapper. The syntax for calling them is a bit uglier though.
- kllrnohj 4y agoYup, but then the call syntax is different so it fails to achieve the "Universal Function Call Syntax" that OP was asking for which std::mem_fn provides.
- gavinray 4y agoWhoa, this is really cool, thanks for posting