This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: /usr/include/c++/*/bits/cmath.tcc (24469)



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




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