/usr/include/c++/*/bits/cmath.tcc (24469)

Daniel Llorens del Río daniel.llorensdelrio@epfl.ch
Tue Jun 6 05:22:00 GMT 2006


On 5 Jun, 2006, at 9:31, libstdc++-digest-help@gcc.gnu.org wrote:

> I found problem with /usr/include/c++/3.3/bits/cmath.tcc.
>
> This line of code:
>
> _Tp __y = __n % 2 ? __x : 1;
>
> isn't correct for some values of template parameter _Tp.
>
> For example, my g++ says somehing like this:
>
> polynomial.hpp:37:   instantiated from `T
> polynomial<T>::calculate(const T&) const [with T =
> std::complex<MpfrClass>]'
> laguerre.cpp:43:   instantiated from here
> /usr/include/c++/3.3/bits/cmath.tcc:41: error: no match for ternary
>   'operator?:' in '((__n % 2) != 0) ? __x : 1'
>
> I think it's better to write
>
> _Tp __y;
> if (__n % 2) __y = __x;
> else __y = 1;
>
> Thanks.

Hi,

I think this is actually a defect in std::complex. There should be an  
implicit conversion from int. Can somebody explain why there is not?

	- Daniel





More information about the Libstdc++ mailing list