When copying boost::ref, copy even when the referenced function is empty. Fixes #2642
Patch by Steven Watanabe