rendered paste body#include <iostream>using namespace std;class NoParameter{ NoParameter() {}};template<typename T>struct CountIfUsed{ enum { value = 1 };};template<>struct CountIfUsed<NoParameter>{ enum { value = 0 };};template< typename T , typename P1 = NoParameter , typename P2 = NoParameter>struct CountParameters{ enum { value = CountIfUsed<P1>::value + CountIfUsed<P2>::value };};template<unsigned params>struct SwitchVisitable{};template<>struct SwitchVisitable<0>{ void foo() { cout << "zero args\n"; }};template<>struct SwitchVisitable<1>{ void foo(int x) { cout << "one arg\n"; }};template<>struct SwitchVisitable<2>{ void foo(int x, int y) { cout << "two args\n"; }};int main() { SwitchVisitable<CountParameters<void, int>::value> obj; obj.foo(1);}