diff --git a/ortools/linear_solver/glop_utils.cc b/ortools/linear_solver/glop_utils.cc index 7c9634e89a..1620653a4a 100644 --- a/ortools/linear_solver/glop_utils.cc +++ b/ortools/linear_solver/glop_utils.cc @@ -13,6 +13,10 @@ #include "ortools/linear_solver/glop_utils.h" +#include "absl/log/log.h" +#include "ortools/linear_solver/linear_solver.h" +#include "ortools/lp_data/lp_types.h" + namespace operations_research { MPSolver::ResultStatus GlopToMPSolverResultStatus(glop::ProblemStatus s) { diff --git a/ortools/set_cover/set_cover_heuristics.cc b/ortools/set_cover/set_cover_heuristics.cc index ef4e344dc5..d9ca035ba0 100644 --- a/ortools/set_cover/set_cover_heuristics.cc +++ b/ortools/set_cover/set_cover_heuristics.cc @@ -240,18 +240,21 @@ namespace { // - improve performance. // - use vectorized code. namespace internal { -uint32_t RawBits(uint32_t x) { return x; } // NOLINT -uint32_t RawBits(int x) { return absl::bit_cast(x); } // NOLINT -uint32_t RawBits(float x) { return absl::bit_cast(x); } // NOLINT -uint64_t RawBits(uint64_t x) { return x; } // NOLINT -uint64_t RawBits(int64_t x) { return absl::bit_cast(x); } // NOLINT -uint64_t RawBits(double x) { return absl::bit_cast(x); } // NOLINT +template +auto RawBits(T x) { + if constexpr (sizeof(T) == sizeof(uint32_t)) { + return absl::bit_cast(x); + } else { + static_assert(sizeof(T) == sizeof(uint64_t)); + return absl::bit_cast(x); + } +} inline uint32_t Bucket(uint32_t x, uint32_t shift, uint32_t radix) { DCHECK_EQ(0, radix & (radix - 1)); // Must be a power of two. // NOMUTANTS -- a way to compute the remainder of a division when radix is a // power of two. - return (RawBits(x) >> shift) & (radix - 1); + return (x >> shift) & (radix - 1); } template