Core: Complex - support for conversion from number values, polyequal support

git-svn-id: svn://ultimatepp.org/upp/trunk@3624 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-07-06 17:23:28 +00:00
parent 682d88d2c6
commit 99c5bc6351

View file

@ -11,7 +11,7 @@ struct Complex : std::complex<double>
Complex(const Nuller&) : C(DOUBLE_NULL) {}
operator Value() const { return RichValue<Complex>(*this); }
Complex(const Value& v) : C(RichValue<Complex>::Extract(v)) {}
Complex(const Value& v) : C(IsNumber(v) ? C((double)v) : RichValue<Complex>::Extract(v)) {}
bool operator==(const Complex& c) const { return (const C&)(*this) == (const C&)c; }
bool operator!=(const Complex& c) const { return (const C&)(*this) != (const C&)c; }
@ -34,5 +34,9 @@ template<> inline dword ValueTypeNo(const Complex*) { return COMPLEX_V; }
inline const Complex& Nvl(const Complex& a, const Complex& b) { return IsNull(a) ? b : a; }
inline bool IsPolyEqual(const Complex& x, const Value& v) {
return IsNumber(v) && x.imag() == 0 && x.real() == (double)v;
}
VALUE_COMPARE(Complex)
NTL_MOVEABLE(Complex)