|
-
October 14th, 2009, 02:36 AM
#4
Re: type precedence in mathematical operations - how is it decided?
I have not thought about it much, but perhaps you can use something from the boost library.
http://www.boost.org/doc/libs/1_40_0...its_class.html
Code:
template <typename T1, typename T2>
inline complex<typename boost::numeric::conversion_traits<T1,T2>::supertype> operator + (const complex<T1> & a, const complex<T2> & b)
{
return complex<typename boost::numeric::conversion_traits<T1,T2>::supertype>(a.real() + b.real(), a.imaginary() + b.imaginary());
}
The problem with this is you seem to want to always promote signed unsigned combinations to unsigned.
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|