octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MSVC compilation problem: std::abs<int64_t> does not exist


From: John W. Eaton
Subject: Re: MSVC compilation problem: std::abs<int64_t> does not exist
Date: Thu, 30 Oct 2008 13:21:40 -0400

On 30-Oct-2008, Abdelrazak Younes wrote:

| On 30/10/2008 16:04, Michael Goffioul wrote:
| > As the subject says, there's no specialization of abs for int64_t type
| > in MSVC. Any idea on how to fix this?
| > (Problem occurs in oct-inttypes.h, line 697).
| 
| template <typename T> T abs(T t) { return t > 0 ? t : -t; }

That's buggy on my system.

For example, try the following program:

  #include <iostream>
  #include <climits>

  template <typename T>
  T
  abs (T t)
  {
    return t > 0 ? t : -t;
  }

  int
  main (void)
  {
    std::cout << LLONG_MAX << std::endl;
    std::cout << LLONG_MIN << ", " << abs (LLONG_MIN) << std::endl;
    std::cout << LLONG_MIN+1 << ", " << abs (LLONG_MIN+1) << std::endl;

    return 0;
  }

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]