abdelkimo / or-tools

Automatically exported from code.google.com/p/or-tools
1 stars 0 forks source link

src\constraint_solver\expressions.cc doesn't build on VS2013 #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build on Windows with Visual Studio 2013

Error to build file src\constraint_solver\expressions.cc, method 
Solver::MakeIntVar

To fix it, add the namespace "std" to the vector instances used inside the 
method:

IntVar* Solver::MakeIntVar(const std::vector<int64>& values, const std::string& 
name) {
  const std::vector<int64> cleaned = SortedNoDuplicates(values);
  int64 gcd = 0;
  for (int64 v : cleaned) {
    if (v == 0) {
      continue;
    }
    if (gcd == 0) {
      gcd = std::abs(v);
    } else {
      gcd = MathUtil::GCD64(gcd, std::abs(v));
    }
    if (gcd == 1) {
      break;
    }
  }
  if (gcd == 1) {
    return RegisterIntVar(RevAlloc(new DomainIntVar(this, cleaned, name)));
  } else {
    std::vector<int64> new_values;
    new_values.reserve(values.size());
    for (int64 v : cleaned) {
      DCHECK_EQ(0, v % gcd);
      new_values.push_back(v / gcd);
    }
    const std::string new_name = name.empty() ? "" : "inner_" + name;
    IntVar* const inner =
        RegisterIntVar(RevAlloc(new DomainIntVar(this, new_values, new_name)));
    return MakeProd(inner, gcd)->Var();
  }
}

Original issue reported on code.google.com by izane...@gmail.com on 19 May 2014 at 6:10

GoogleCodeExporter commented 9 years ago
Fixed, thanks

Original comment by laurent....@gmail.com on 21 May 2014 at 1:50

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 21 May 2014 at 1:50