From 89a84919144eadb3aead61b6243df9cd350daa84 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 25 Apr 2015 01:25:42 +0200 Subject: [PATCH] minor changes --- src/json.hpp | 19 ++++++++++--------- src/json.hpp.re2c | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 04bd1acd..a61ad51b 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -504,14 +504,15 @@ class basic_json {} /// create a container (array or object) from an initializer list - inline basic_json(list_init_t l, bool type_deduction = true, value_t manual_type = value_t::array) + inline basic_json(list_init_t init, bool type_deduction = true, + value_t manual_type = value_t::array) { // the initializer list could describe an object bool is_object = true; // check if each element is an array with two elements whose first element // is a string - for (const auto& element : l) + for (const auto& element : init) { if ((element.m_final and element.m_type == value_t::array) or (element.m_type != value_t::array or element.size() != 2 @@ -551,7 +552,7 @@ class basic_json m_value.object = alloc.allocate(1); alloc.construct(m_value.object); - for (auto& element : l) + for (auto& element : init) { m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1])); } @@ -562,20 +563,20 @@ class basic_json m_type = value_t::array; AllocatorType alloc; m_value.array = alloc.allocate(1); - alloc.construct(m_value.array, std::move(l)); + alloc.construct(m_value.array, std::move(init)); } } /// explicitly create an array from an initializer list - inline static basic_json array(list_init_t l = list_init_t()) + inline static basic_json array(list_init_t init = list_init_t()) { - return basic_json(l, false, value_t::array); + return basic_json(init, false, value_t::array); } /// explicitly create an object from an initializer list - inline static basic_json object(list_init_t l = list_init_t()) + inline static basic_json object(list_init_t init = list_init_t()) { - return basic_json(l, false, value_t::object); + return basic_json(init, false, value_t::object); } /// construct an array with count copies of given value @@ -764,6 +765,7 @@ class basic_json std::is_nothrow_move_assignable::value ) { + using std::swap; std::swap(m_type, other.m_type); std::swap(m_value, other.m_value); return *this; @@ -3374,7 +3376,6 @@ class basic_json case (basic_json::value_t::object): { throw std::domain_error("cannot use operator+= for object iterators"); - break; } case (basic_json::value_t::array): diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 48682339..3677557b 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -504,14 +504,15 @@ class basic_json {} /// create a container (array or object) from an initializer list - inline basic_json(list_init_t l, bool type_deduction = true, value_t manual_type = value_t::array) + inline basic_json(list_init_t init, bool type_deduction = true, + value_t manual_type = value_t::array) { // the initializer list could describe an object bool is_object = true; // check if each element is an array with two elements whose first element // is a string - for (const auto& element : l) + for (const auto& element : init) { if ((element.m_final and element.m_type == value_t::array) or (element.m_type != value_t::array or element.size() != 2 @@ -551,7 +552,7 @@ class basic_json m_value.object = alloc.allocate(1); alloc.construct(m_value.object); - for (auto& element : l) + for (auto& element : init) { m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1])); } @@ -562,20 +563,20 @@ class basic_json m_type = value_t::array; AllocatorType alloc; m_value.array = alloc.allocate(1); - alloc.construct(m_value.array, std::move(l)); + alloc.construct(m_value.array, std::move(init)); } } /// explicitly create an array from an initializer list - inline static basic_json array(list_init_t l = list_init_t()) + inline static basic_json array(list_init_t init = list_init_t()) { - return basic_json(l, false, value_t::array); + return basic_json(init, false, value_t::array); } /// explicitly create an object from an initializer list - inline static basic_json object(list_init_t l = list_init_t()) + inline static basic_json object(list_init_t init = list_init_t()) { - return basic_json(l, false, value_t::object); + return basic_json(init, false, value_t::object); } /// construct an array with count copies of given value @@ -764,6 +765,7 @@ class basic_json std::is_nothrow_move_assignable::value ) { + using std::swap; std::swap(m_type, other.m_type); std::swap(m_value, other.m_value); return *this; @@ -3374,7 +3376,6 @@ class basic_json case (basic_json::value_t::object): { throw std::domain_error("cannot use operator+= for object iterators"); - break; } case (basic_json::value_t::array):