class RunAround;
class HopUpAndDown;
class Sleep;
template<typename Acts> int doThis();
template<> int doThis<RunAround>() { /* run run run.. */ return 3; }
template<> int doThis<HopUpAndDown>() { /* hop hop hop.. */ return 2; }
template<> int doThis<Sleep>() { /* zzz.. */ return -2; }
struct Results
{
template<typename Act> int& operator()()
{
static int result;
return result;
}
};
int main()
{
Results results;
//results<RunAround>() = doThis<RunAround>();
results.operator ()<RunAround>() = doThis<RunAround>();
results.operator ()<Sleep>() = doThis<Sleep>();
return 0;
};
If I remove the comment, the compiler thinks I am calling operator()
in non-existant template class Results<RunAround>
when I want operator<RunAround>()
in class Results
.
If I want to continue using an operator overload instead of a normal name, am I doomed to use the awful syntax below the comment (which does work)?