octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #65244] Simplify code complexity of perms.cc


From: anonymous
Subject: [Octave-bug-tracker] [bug #65244] Simplify code complexity of perms.cc
Date: Fri, 9 Feb 2024 08:45:42 -0500 (EST)

Follow-up Comment #13, bug#65244 (group octave):

A similar code that doesn't compile on both gcc and clang:
  

#include <type_traits>
#include <vector>

struct octave_value
{
  octave_value ():val(0.0) {}
  explicit octave_value (double d) :val(d){}
  bool is_equal(const octave_value& b)
  {
    return val = b.val;
  }
  
  double val;
};

template <typename T>
bool perm ()
{
  std::vector <T> Ar;
  Ar.push_back(T(2.0) );
  Ar.push_back(T(3.0) );
  static constexpr bool is_same_type = std::is_same<T, octave_value>::value;
  
  if (is_same_type)
    return Ar[0].is_equal (Ar[1]);
  else
   return (Ar[0] == Ar[1]);
}

int main()
{
    perm<double>();
    perm<octave_value>();
}




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65244>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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