Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualEctara

Posted 05 January 2013 - 10:04 AM

You could add in either explicit int overloads or some template operator overloads. Ex:

template <typename T>
Int64 operator *(const Int64 & x, T y) {
  Int64 temp;
  temp = y;
  return (x * temp);
}

template <typename T>
Int64 operator *(T x, const Int64 & y) {
  return y * x;
}

The thing is, I did (the last two overloads of  operator * in my posted code), however, the compiler declares it ambiguous whether it should use these overloads, or use the conversion operator to convert the Int64 to the fundamental type, then do built-in math with it.


#1Ectara

Posted 05 January 2013 - 10:03 AM

You could add in either explicit int overloads or some template operator overloads. Ex:

template <typename T>
Int64 operator *(const Int64 & x, T y) {
  Int64 temp;
  temp = y;
  return (x * temp);
}

template <typename T>
Int64 operator *(T x, const Int64 & y) {
  return y * x;
}

The thing is, I did (the last two overloads of  operator * in my posted code), however, the compiler declares it ambiguous whether it should use these overloads, or use the conversion operator to convert it to the fundamental type, then do built-in math with it.


PARTNERS