?
=?ISO-8859-1?Q?Daniel_Sch=FCle?=
hello all,
#include <iostream>
#include <cstdlib>
using namespace std;
struct test
{
operator signed int(){ cout << "SINT" << endl; return -1; }
operator unsigned int(){ cout << "UINT" << endl; return 1; }
operator float(){ cout << "F" << endl; return 0.0; }
operator double(){ cout << "D" << endl; return 0.0; }
};
template <typename stype, typename utype>
void int_test()
{
test t;
stype s;
utype u;
t + s, t + u;
}
template <typename type>
void float_test()
{
test t;
type x;
t + x;
}
int main()
{
int_test<signed int, unsigned int>(); // 1
int_test<signed char, unsigned char>(); // 2
float_test<float>(); // 3
float_test<double>(); // 4
system("PAUSE");
return 0;
}
1, 2, 3, 4 all of them are ambigious calls
double(1) + t
shouldn't this invoke test:perator double()?
Thx in advance
-Daniel
#include <iostream>
#include <cstdlib>
using namespace std;
struct test
{
operator signed int(){ cout << "SINT" << endl; return -1; }
operator unsigned int(){ cout << "UINT" << endl; return 1; }
operator float(){ cout << "F" << endl; return 0.0; }
operator double(){ cout << "D" << endl; return 0.0; }
};
template <typename stype, typename utype>
void int_test()
{
test t;
stype s;
utype u;
t + s, t + u;
}
template <typename type>
void float_test()
{
test t;
type x;
t + x;
}
int main()
{
int_test<signed int, unsigned int>(); // 1
int_test<signed char, unsigned char>(); // 2
float_test<float>(); // 3
float_test<double>(); // 4
system("PAUSE");
return 0;
}
1, 2, 3, 4 all of them are ambigious calls
double(1) + t
shouldn't this invoke test:perator double()?
Thx in advance
-Daniel