diff --git a/ext/or-tools/constraint.cpp b/ext/or-tools/constraint.cpp index 834294d..5ba628f 100644 --- a/ext/or-tools/constraint.cpp +++ b/ext/or-tools/constraint.cpp @@ -67,26 +67,6 @@ namespace Rice::detail return expr; } }; - - template<> - class From_Ruby> - { - public: - std::vector convert(VALUE v) - { - auto a = Array(v); - std::vector vec; - vec.reserve(a.size()); - for (const Object v : a) { - if (v.is_a(rb_cSatIntVar)) { - vec.push_back(From_Ruby().convert(v.value()).ToBoolVar()); - } else { - vec.push_back(From_Ruby().convert(v.value())); - } - } - return vec; - } - }; } void init_constraint(Rice::Module& m) { @@ -110,7 +90,17 @@ void init_constraint(Rice::Module& m) { return self.OnlyEnforceIf(Rice::detail::From_Ruby().convert(literal).ToBoolVar()); } else if (literal.is_a(rb_cArray)) { // TODO support IntVarSpan - return self.OnlyEnforceIf(Rice::detail::From_Ruby>().convert(literal)); + auto a = Array(literal); + std::vector vec; + vec.reserve(a.size()); + for (const Object v : a) { + if (v.is_a(rb_cSatIntVar)) { + vec.push_back(Rice::detail::From_Ruby().convert(v.value()).ToBoolVar()); + } else { + vec.push_back(Rice::detail::From_Ruby().convert(v.value())); + } + } + return self.OnlyEnforceIf(vec); } else { return self.OnlyEnforceIf(Rice::detail::From_Ruby().convert(literal)); } diff --git a/ext/or-tools/routing.cpp b/ext/or-tools/routing.cpp index 72aece6..18b932b 100644 --- a/ext/or-tools/routing.cpp +++ b/ext/or-tools/routing.cpp @@ -56,19 +56,6 @@ namespace Rice::detail }; } -namespace Rice::detail -{ - template - class To_Ruby> - { - public: - VALUE convert(std::pair const & x) - { - return rb_ary_new3(2, To_Ruby().convert(x.first), To_Ruby().convert(x.second)); - } - }; -} - void init_routing(Rice::Module& m) { auto rb_cRoutingSearchParameters = Rice::define_class_under(m, "RoutingSearchParameters"); auto rb_cIntVar = Rice::define_class_under(m, "IntVar");