|
Boost Users : |
Subject: [Boost-users] [enable_if] Doesn't work for static member functions ?
From: Jean-Louis Leroy (jl_at_[hidden])
Date: 2009-09-23 16:54:42
Consider :
template<typename U>
struct Test {
template<typename T>
typename enable_if<is_same<T, int>, void>::type test() {
cout << "int" << endl;
}
template<typename T>
typename enable_if<is_same<T, char>, void>::type test() {
cout << "char" << endl;
}
};
template<typename T>
typename enable_if<is_same<T, int>, void>::type test() {
cout << "int" << endl;
}
template<typename T>
typename enable_if<is_same<T, char>, void>::type test() {
cout << "char" << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
test<int>();
test<char>();
Test<int>::test<double>(); // error
return 0;
}
MSVC9 will give a compilation error (see below) where marked. Am I
missing something obvious ?
Thanks,
J-L
1>c:\users\jll\documents\visual studio
2008\projects\boost_1_40_0\libs\rdb\test\test.cpp(325) : error C2143:
syntax error : missing ';' before '<'
1> c:\users\jll\documents\visual studio
2008\projects\boost_1_40_0\libs\rdb\test\test.cpp(333) : see reference
to class template instantiation 'Test<U>' being compiled
1>c:\users\jll\documents\visual studio
2008\projects\boost_1_40_0\libs\rdb\test\test.cpp(325) : error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int
etc etc etc
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net