From 4c3423b489646ba66fd44be6f1c7f2ba4802bdb9 Mon Sep 17 00:00:00 2001 From: stevenj Date: Mon, 5 Apr 2010 03:28:11 -0400 Subject: [PATCH] catch a vector-size mismatch in C++ darcs-hash:20100405072811-c8de0-307c0f8c22e707816cbe2da178b2ff92fc6a596f.gz --- api/nlopt-in.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/nlopt-in.hpp b/api/nlopt-in.hpp index a4d9144..cc09c44 100644 --- a/api/nlopt-in.hpp +++ b/api/nlopt-in.hpp @@ -109,6 +109,8 @@ namespace nlopt { return result(ret); } result optimize(std::vector &x, double &opt_f) { + if (o && nlopt_get_dimension(o) != x.size()) + throw std::invalid_argument("dimension mismatch"); return optimize(x.empty() ? NULL : &x[0], opt_f); } -- 2.30.2