Browse Source

Clean up construction of exceptions and such

Sam Jaffe 8 years ago
parent
commit
109ef7b354
2 changed files with 8 additions and 8 deletions
  1. 2 2
      json_binder.hpp
  2. 6 6
      json_common.hpp

+ 2 - 2
json_binder.hpp

@@ -59,7 +59,7 @@ namespace json {
       void parse(char const* data, parser::options opts) {
         b.parse(obj, data, opts);
         if ( json::helper::get_next_element(data) && opts & parser::disable_concatenated_json_bodies ) {
-          throw malformed_json_exception{"Config set to require json input be terminated"};
+          throw malformed_json_exception("Config set to require json input be terminated");
         }
       }
       
@@ -74,7 +74,7 @@ namespace json {
     
     template <typename T, typename S>
     visitor<T, S> bind(S& object, binder_impl<T>& b) {
-      return visitor<T, S>{object, b};
+      return {object, b};
     }
   }
   

+ 6 - 6
json_common.hpp

@@ -130,9 +130,9 @@ namespace json { namespace helper {
     errno = 0;
     T tmp = parse_double_impl<T>(begin, data);
     if (errno != 0) {
-      throw json::json_numeric_width_exception{"Number is out-of-range for floating-point type"};
+      throw json::json_numeric_width_exception("Number is out-of-range for floating-point type");
     } else if ( begin == data ) {
-      throw json::json_numeric_exception{"Expected numeric data"};
+      throw json::json_numeric_exception("Expected numeric data");
     }
     errno = 0;
     json = std::move(tmp);
@@ -143,13 +143,13 @@ namespace json { namespace helper {
     json::helper::get_next_element(data);
     numeric_token_info info = data;
     if ( info.is_negative && !std::is_signed<J>::value ) {
-      throw json_numeric_exception{"Expected signed integer"};
+      throw json_numeric_exception("Expected signed integer");
     } else if ( info.is_double || info.parse_numeric() == DOUBLE ) {
-      throw json_numeric_exception{"Expected integer, got double"};
+      throw json_numeric_exception("Expected integer, got double");
     } else if (info.base == numeric_token_info::decimal &&
                (fls(static_cast<int_jt>(info.val)) > std::numeric_limits<J>::digits + info.is_negative
                || info.val > json::numeric_limits<J>::over)) {
-      throw json_numeric_width_exception{"Integer width too small for parsed value"};
+      throw json_numeric_width_exception("Integer width too small for parsed value");
     } else if (info.is_negative) {
       if (info.val == json::numeric_limits<J>::over) {
         json = json::numeric_limits<J>::min;
@@ -160,7 +160,7 @@ namespace json { namespace helper {
       json = static_cast<J>(int_jt(info.val));
     } else if (std::is_signed<J>::value &&
                info.base == numeric_token_info::decimal) {
-      throw json_numeric_exception{"Expected unsigned integer"};
+      throw json_numeric_exception("Expected unsigned integer");
     } else {
       json = static_cast<J>(info.val);
     }