
21 Feb
2008
21 Feb
'08
7 p.m.
Alexander Nasonov <alnsn <at> yandex.ru> writes:
struct Cases { template<class N> void operator()(N) const { ... }
void operator()(default_t) const { ... } };
The trick posted on RSDN lets me check whether the last call operator exists and take this into account.
One useful generalisation of this trick is something like
result_of_with_default<void (Cases)(default_t), no_default_case>
In order for the above to work, Cases::operator()(N) must be more specialised: struct Cases { template<int N> void operator()(mpl::int_<N>) const { ... } // void operator()(default_t) const { ... } }; So, result_of_with_default<Cases(default_t), no_default_case>::type would be no_default_case. Alex