Boost logo

Ublas :

Subject: Re: [ublas] enable complex @ int
From: Matwey V. Kornilov (matwey.kornilov_at_[hidden])
Date: 2009-09-29 03:54:09


Neal Becker wrote:

> I use this patch to traits.hpp:
>
> ***************
> *** 40,45 ****
> --- 41,81 ----
>
> namespace boost { namespace numeric { namespace ublas {
>
> + typedef std::complex<double> complex_t;
> +
> + inline complex_t operator+ (int in1, complex_t in2) {
> + return double(in1) + in2;
> + }

I think it would be better to write in such way:

template<R> std::complex<R> operator+ (int in1, const std::complex<R>& in2 ){
    return typename std::complex<R>::value_type(in1) + in2;
}