I'm trying to change some macros (we have a bunch of them) for function templates. Many times, I have the following scenario:
#include <iostream>
void function_A( void )
{
std::cout << "function A" << std::endl;
}
void function_B( void )
{
std::cout << "function B" << std::endl;
}
#define FOO( _bar ) \
do { \
/* ... do something */ \
function_##_bar(); \
/* ... do something */ \
} while( 0 )
int main()
{
FOO( A );
FOO( B );
}
How can I express FOO
as a function template and achieve the same result?
I am thinking in something like:
template < ??? _bar >
void foo()
{
// somehow link function_X and _bar
}
Performance is a must!!
Thanks in advance.