Item 46. Forwarding Functions
Difficulty: 3
What's the best way to write a forwarding function? The basic answer is easy, but we'll also learn about a subtle change to the language made shortly before the standard was finalized.
Forwarding functions are useful tools for handing off work to another function or object, especially when the hand-off is done efficiently.
Critique the following forwarding function. Would you change it? If so, how?
// file f.cpp
//
#include "f.h"
/*...*/
bool f( X x )
{
return g( x );
}
|