chiark / gitweb /
some C++ tweaks
authorstevenj <stevenj@alum.mit.edu>
Mon, 5 Apr 2010 06:30:16 +0000 (02:30 -0400)
committerstevenj <stevenj@alum.mit.edu>
Mon, 5 Apr 2010 06:30:16 +0000 (02:30 -0400)
darcs-hash:20100405063016-c8de0-5560baf07043e1495a4e1315acbc280f6105af39.gz

api/nlopt-in.hpp

index 5285c62f99f89ec4048bc4f2fb725a65eb1a9158..dd76746d3f1be0704874127b9bbff86ad376f0e9 100644 (file)
@@ -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<double> get_##name(void) const {                       \
-      if (!o) throw std::invalid_argument("uninitialized nlopt::opt"); \
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");    \
       std::vector<double> 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<double> get_initial_step(const std::vector<double> &x) const {
-      if (!o) throw std::invalid_argument("uninitialized nlopt::opt");
+      if (!o) throw std::runtime_error("uninitialized nlopt::opt");
       std::vector<double> v(nlopt_get_dimension(o));
       get_initial_step(x, v);
       return v;
     }
   };
 
+#undef NLOPT_GETSET
+#undef NLOPT_GETSET_VEC
+
   //////////////////////////////////////////////////////////////////////
 
 } // namespace nlopt