The following code is, as far as I know, standard C++. It compiles on gcc but Visual Studio 2008 and 2010 fail to compile it. namespace cool { template <bool, typename = void> struct enable_if {}; template <typename T> struct enable_if<true, T> { typedef T type; }; template <typename T0, typename T1> struct is_same { enum { value = false }; }; template <typename T> struct is_same<T, T> { enum { value = true }; }; } struct BasePolicy {}; struct BasePolicy2 {}; struct Faz {}; template <typename Policy, typename = typename cool::enable_if<cool::is_same<BasePolicy, Policy>::value || cool::is_same<BasePolicy2, Policy>::value>::type > struct Foo; template <typename Policy> struct Foo<Policy> { Foo(); }; template <typename Policy> Foo<Policy>::Foo() { } int main() { Foo<BasePolicy2> fb; }Moving the constructor BACK to the class itself (i.e. the definition is now in-line so that the declaration is the definition as well) fixes the issue:namespace cool{ template <bool, typename = void> struct enable_if {}; template <typename T> struct enable_if<true, T> { typedef T type; }; template <typename T0, typename T1> struct is_same { enum { value = false }; }; template <typename T> struct is_same<T, T> { enum { value = true }; };}struct BasePolicy {};struct BasePolicy2 {};struct Faz {};template <typename Policy, typename = typename cool::enable_if<cool::is_same<BasePolicy, Policy>::value || cool::is_same<BasePolicy2, Policy>::value>::type >struct Foo;template <typename Policy>struct Foo<Policy> { Foo() {}};int main(){ Foo<BasePolicy2> fb;}
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...