From 98a131d21b061022413fcc03b15894a161c999f6 Mon Sep 17 00:00:00 2001 From: stevenj Date: Mon, 5 Apr 2010 02:30:16 -0400 Subject: [PATCH] some C++ tweaks darcs-hash:20100405063016-c8de0-5560baf07043e1495a4e1315acbc280f6105af39.gz --- api/nlopt-in.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/api/nlopt-in.hpp b/api/nlopt-in.hpp index 5285c62..dd76746 100644 --- a/api/nlopt-in.hpp +++ b/api/nlopt-in.hpp @@ -114,11 +114,11 @@ namespace nlopt { // accessors: algorithm get_algorithm() const { - if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); + if (!o) throw std::runtime_error("uninitialized nlopt::opt"); return algorithm(nlopt_get_algorithm(o)); } unsigned get_dimension() const { - if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); + if (!o) throw std::runtime_error("uninitialized nlopt::opt"); return nlopt_get_dimension(o); } @@ -176,7 +176,7 @@ namespace nlopt { get_##name(v.empty() ? NULL : &v[0]); \ } \ std::vector get_##name(void) const { \ - if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); \ + if (!o) throw std::runtime_error("uninitialized nlopt::opt"); \ std::vector v(nlopt_get_dimension(o)); \ get_##name(v); \ return v; \ @@ -194,7 +194,7 @@ namespace nlopt { #define NLOPT_GETSET(T, name) \ T get_##name() const { \ - if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); \ + if (!o) throw std::runtime_error("uninitialized nlopt::opt"); \ return nlopt_get_##name(o); \ } \ void set_##name(T name) { \ @@ -241,13 +241,16 @@ namespace nlopt { dx.empty() ? NULL : &dx[0]); } std::vector get_initial_step(const std::vector &x) const { - if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); + if (!o) throw std::runtime_error("uninitialized nlopt::opt"); std::vector v(nlopt_get_dimension(o)); get_initial_step(x, v); return v; } }; +#undef NLOPT_GETSET +#undef NLOPT_GETSET_VEC + ////////////////////////////////////////////////////////////////////// } // namespace nlopt -- 2.30.2