Class template spec with enable_if
Hello again!
See the example below. (Platform: VC++7.1)
This error is strange for me because it only occurs in the case of class
template
specialization.
The compiler deduces the type of is_arithmetic<T>::value falsely, not
as bool, althought it is known at compile time, isn't it?
The error messages (both referring to the erroneous line marked with
"ERROR"):
error C2296: '&&' : illegal, left operand has type 'is_arithmetic<T>::value'
error C2297: '&&' : illegal, right operand has type
'is_arithmetic<T2>::value'
Thx,
Agoston
Example:
//-------------------------------------------------------
#include <iostream>
#include ::type // ERROR!!! {
static const bool value = true;
};
*/
/*
//WOULD WORK:
typename enable_if<
and_< is_arithmetic<T1>, is_arithmetic<T2> > ::type
*/ // -----------------
template ::type
f(T1 t1, T2 t2) { cout << t1 << " " << t2 << endl; } // -----------------
int _tmain(int argc, _TCHAR* argv[])
{
f(5.0, 6);
return 0;
}
participants (1)
-
Agoston Bejo