H
Hicham Mouline
Hello,
I have a function template whose arguments specify policy inside a tight
loop
struct DefaultPolicy {
void operator()(...)
{
}
};
struct OtherPolicy{
void operator()(...)
{
// do something
}
};
template <typename T1, typename Policy>
void f( const T1& t1, const Policy& policy = DefaultPolicy() )
{
for (...)
for (...)
{
// get first result
policy ( result );
}
}
}
so that the user can call f without specifying the template arguments,
just the T1 arg, and sometimes the policy arg too.
Ideally, the policy ( result ) call would be totally optimized away by the
compiler if it's the default one.
Does this seem a reasonable pattern?
regards,
I have a function template whose arguments specify policy inside a tight
loop
struct DefaultPolicy {
void operator()(...)
{
}
};
struct OtherPolicy{
void operator()(...)
{
// do something
}
};
template <typename T1, typename Policy>
void f( const T1& t1, const Policy& policy = DefaultPolicy() )
{
for (...)
for (...)
{
// get first result
policy ( result );
}
}
}
so that the user can call f without specifying the template arguments,
just the T1 arg, and sometimes the policy arg too.
Ideally, the policy ( result ) call would be totally optimized away by the
compiler if it's the default one.
Does this seem a reasonable pattern?
regards,