This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: abs(int) missing
- To: sxking at uswest dot net
- Subject: Re: abs(int) missing
- From: Levente Farkas <lfarkas at mindmaker dot hu>
- Date: Thu, 17 Aug 2000 17:38:32 +0200
- Cc: STDC++ <libstdc++ at sources dot redhat dot com>
- Organization: Mindmaker Ltd.
- References: <399BDEA9.924810AE@mindmaker.hu> <00081708301100.00792@rigel>
- Reply-To: lfarkas at mindmaker dot hu
Steven King wrote:
>
> On Thu, 17 Aug 2000, Levente Farkas wrote:
> > hi,
> > it seems to me that abs(int) is missing from std namespace!!!
> > -----------------------
> > #include <cmath>
> >
> > int main()
> > {
> > int i = std::abs(4);
> > return 0;
> > }
>
> No, its there. std::abs (int) (and std::abs (long)) is defined in cstdlib;
> cmath add overloads for float, double and long long double and is not required
> to define std::abs (int). see 26.5 of the standard.
these are still not working
#include <cmath>
#include <cstdlib>
int main()
{
int i = std::abs(4);
return 0;
}
g++ -fhonor-std test.cpp
test.cpp: In function `int main ()':
test.cpp:5: call of overloaded `abs (int)' is ambiguous
/usr/include/g++-v3/bits/std_cmath.h:52: candidates are: float std::abs (float)
/usr/include/g++-v3/bits/std_cmath.h:262: double std::abs
(double)
/usr/include/g++-v3/bits/std_cmath.h:362: long double std::abs
(long double)
-- Levente
"The only thing worse than not knowing the truth is
ruining the bliss of ignorance."