This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with implicit conversion (GCC 3.4.1)


Try the code below. You could use std::min template in STL, so that you can force conversion
to the template parameter.


template<class T> class BasisF {
	T x;
public:

	BasisF(const T &_x = T()): x(_x) {}
	BasisF(const BasisF &_b): x(_b.x) {}
	~BasisF() {}

	BasisF& operator= (const T &_x){
		 x(_x);
		 return *this;
	}

	friend bool operator<=(const BasisF &a, const BasisF &b) {
		return a.x <= b.x;
	}
};

#define min(a,b) ((a) <= (b) ? (a) : (b))

int main(){
	BasisF<double> t(1);
	if (min(t, 2.0)<= 0) {
		return 1;
	}

	return 0;
}

Thanks,
L.Suresh.

_________________________________________________________________
Sell what you don?t Need.We help you Ship it out. http://go.msnserver.com/IN/54179.asp Click Here!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]