
On Fri, Apr 8, 2011 at 9:59 AM, Gennadiy Rozental
Hi,
It's late and I might be missing something, but I can't figure out how can I use enable_if to disambiguate 2 partial specializations where one is subcase of another one:
#include
#include #include #include <iostream>
template
struct M { static void foo() { std::cout << "generic" << std::endl; } }; template<typename T> struct M
::type> { static void foo() { std::cout << "scalar" << std::endl; } }; template<typename T> struct M
::type> { static void foo() { std::cout << "enum" << std::endl; } }; struct S {}; enum FOO { FOO1, FOO2 };
int main() { M<S>::foo(); M<int>::foo(); M<FOO>::foo(); }
---------------
M<FOO>::foo() fails to compile due to ambiguity.
Any pointers? Or How to get what I want?
I'm assuming the problem is that the scalar case is also true for the enum case? On that basis, could you not us an enabler that asks if it is scalar && ! enum? - Rob. (That's just off the cuff - I 'spect a proper expert will be along soon!)