Re: Near identical overloads with SFINAE in C++0X
On 18 Apr., 22:27, Noah Roberts wrote:
Don't know why the hostility.
I wouldn't say "hostility". It's just my honest feedback without any
sugar coding. Pointing out that I *think* you misunderstood something
and flaws of the code you presented is not hostile behaviour, is it?
Maybe it was a little bit snarky. But what do you expect? The code did
not work for several reasons.
The OP's problem has nothing,
specifically to do with variadic templates.
Marc intended to enable/disable depending on sizeof...(U) where
sizeof... is a new operator whith takes a parameter pack and returns
its size.
[...] I welcome you to provide your own answer.
I'd say, an improvement of your dispatching idea could look like this:
template<int N> struct int2type
{ static const int value=N; };
template<class...Args>
void f_impl(int2type<2>, Args&&...args) {}
template<class...Args>
void f_impl(int2type<3>, Args&&...args) {}
template<class...Args>
inline void f(Args&&...args) {
f_impl(int2type<sizeof...(Args)>(),forward<Args>(args)...);
}
(untested)
SG