From cf829ac2e8571685177c46be6860b56472e0d4df Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 22 Mar 2015 17:50:43 +0100 Subject: [PATCH] fixed deprecated warnings in issue #42 --- src/json.hpp | 34 ++++++++++++++++++++++++++++------ src/json.hpp.re2c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 3aad611b..89269ea3 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2072,11 +2072,22 @@ class basic_json } } + /// copy constructor + inline iterator(const iterator& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + /// copy assignment - inline iterator& operator=(const iterator& other) noexcept + inline iterator& operator=(iterator other) noexcept ( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible>::value + and + std::is_nothrow_move_assignable>::value + ) { - m_object = other.m_object; - m_it = other.m_it; + std::swap(m_object, other.m_object); + std::swap(m_it, other.m_it); return *this; } @@ -2575,11 +2586,22 @@ class basic_json } } + /// copy constructor + inline const_iterator(const const_iterator& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + /// copy assignment - inline const_iterator& operator=(const const_iterator& other) noexcept + inline const_iterator& operator=(const_iterator other) noexcept( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible>::value + and + std::is_nothrow_move_assignable>::value + ) { - m_object = other.m_object; - m_it = other.m_it; + std::swap(m_object, other.m_object); + std::swap(m_it, other.m_it); return *this; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 0829e9b1..5ebda5a7 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -2072,11 +2072,22 @@ class basic_json } } + /// copy constructor + inline iterator(const iterator& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + /// copy assignment - inline iterator& operator=(const iterator& other) noexcept + inline iterator& operator=(iterator other) noexcept ( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible>::value + and + std::is_nothrow_move_assignable>::value + ) { - m_object = other.m_object; - m_it = other.m_it; + std::swap(m_object, other.m_object); + std::swap(m_it, other.m_it); return *this; } @@ -2575,11 +2586,22 @@ class basic_json } } + /// copy constructor + inline const_iterator(const const_iterator& other) noexcept + : m_object(other.m_object), m_it(other.m_it) + {} + /// copy assignment - inline const_iterator& operator=(const const_iterator& other) noexcept + inline const_iterator& operator=(const_iterator other) noexcept( + std::is_nothrow_move_constructible::value and + std::is_nothrow_move_assignable::value and + std::is_nothrow_move_constructible>::value + and + std::is_nothrow_move_assignable>::value + ) { - m_object = other.m_object; - m_it = other.m_it; + std::swap(m_object, other.m_object); + std::swap(m_it, other.m_it); return *this; }