From: stevenj Date: Mon, 5 Apr 2010 06:30:16 +0000 (-0400) Subject: some C++ tweaks X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=98a131d21b061022413fcc03b15894a161c999f6;p=nlopt.git some C++ tweaks darcs-hash:20100405063016-c8de0-5560baf07043e1495a4e1315acbc280f6105af39.gz --- 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