Hi,
I am having some trouble using enable_if with gcc 3.4.4 (code below). Basically it is working as expected with functions ("bar"), but using it on member functions of a class ("Foo"), I am getting the error that this member function cannot be overloaded.
Visual 2008 and gcc4 seem to be ok with it though.
Any explanation and work around appreciated.
B.
--
#include <iostream>
#include
#include
// This won't compile with gcc 3.4.4
class Foo
{
public:
template < typename T >
typename boost::enable_if, T>::type
bar(int x)
{
std::cout << "A" << std::endl;
return x;
}
template < typename T >
typename boost::disable_if, T>::type
bar(int x)
{
std::cout << "B" << std::endl;
return x;
}
};
// this would.
template < typename T >
typename boost::enable_if, T>::type
bar(int x)
{
std::cout << "A" << std::endl;
return x;
}
template < typename T >
typename boost::disable_if, T>::type
bar(int x)
{
std::cout << "B" << std::endl;
return x;
}
int main()
{
bar<int>(1);
bar<double>(1);
Foo f;
f.bar<int>(1);
f.bar<double>(1);
return 0;
}
____________________________________________________
Michael Jackson, Susan Boyle, Black Eyed Peas ... Retrouvez leurs derniers titres sur http://musiline.voila.fr