In folgendem Code wird von VC++ wie gewünscht das Template ausgewählt:
Code: Alles auswählen
struct FooBar
{
};
class Foo
{
public:
template<typename T> static void bar(T t){}
static void bar(FooBar b){}
};
int main(void)
{
Foo foo;
foo.bar(1);
}
Code: Alles auswählen
struct FooBar
{
};
class Foo
{
public:
template<typename T> static void bar(typename std::enable_if<!std::is_pointer<T>::value,T>::type t){}
static void bar(FooBar b){}
};
int main(void)
{
foo::bar(1);
}
Jemand eine Idee, wieso das so ist und wie man den Compiler dazu bekommt, trotzt dependant name lookup das Template zu wählen?error C2664: 'void Foo::bar(FooBar)' : cannot convert parameter 1 from 'int' to 'FooBar'
Edit:
Code simplifiziert und vereinheitlicht.
Edit2: überflüssige Semikola entfernt.