summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthäus Brandl <brandl.matthaeus@gmail.com>2018-03-02 05:13:43 +0100
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2018-03-01 20:13:43 -0800
commit8284dbf61d85d82d17060dc34528d07a92829b40 (patch)
treecc74eee65cc19a8a3a35b0735b0142eb557edf20
parent41219a5a207a25ff16f661fae280523084c12dc3 (diff)
Add noexcept specifiers to move special members where possible (#183)
* Adds a macro definition to be able to use noexcept with supporting compilers * Adds noexcept specifier to move special members of xpath_node_set, xpath_variable_set and xpath_query, but not of xml_document as it has a throwing implementation
-rw-r--r--src/pugixml.cpp14
-rw-r--r--src/pugixml.hpp28
2 files changed, 28 insertions, 14 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index a6930a1..6f6aac8 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -12044,7 +12044,7 @@ namespace pugi
}
#ifdef PUGIXML_HAS_MOVE
- PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs)
+ PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) PUGIXML_NOEXCEPT
{
_type = rhs._type;
_storage = rhs._storage;
@@ -12087,12 +12087,12 @@ namespace pugi
}
#ifdef PUGIXML_HAS_MOVE
- PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs): _type(type_unsorted), _begin(&_storage), _end(&_storage)
+ PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(&_storage), _end(&_storage)
{
_move(rhs);
}
- PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs)
+ PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT
{
if (this == &rhs) return *this;
@@ -12287,7 +12287,7 @@ namespace pugi
}
#ifdef PUGIXML_HAS_MOVE
- PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs)
+ PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT
{
for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i)
{
@@ -12296,7 +12296,7 @@ namespace pugi
}
}
- PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs)
+ PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT
{
for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i)
{
@@ -12490,7 +12490,7 @@ namespace pugi
}
#ifdef PUGIXML_HAS_MOVE
- PUGI__FN xpath_query::xpath_query(xpath_query&& rhs)
+ PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT
{
_impl = rhs._impl;
_result = rhs._result;
@@ -12498,7 +12498,7 @@ namespace pugi
rhs._result = xpath_parse_result();
}
- PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs)
+ PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT
{
if (this == &rhs) return *this;
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 9277384..a0dd0e4 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -81,6 +81,20 @@
# endif
#endif
+// If C++ is 2011 or higher, add 'noexcept' specifiers
+#ifndef PUGIXML_HAS_NOEXCEPT
+# if __cplusplus >= 201103
+# define PUGIXML_HAS_NOEXCEPT
+# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
+# define PUGIXML_HAS_NOEXCEPT
+# endif
+#endif
+#ifdef PUGIXML_HAS_NOEXCEPT
+# define PUGIXML_NOEXCEPT noexcept
+#else
+# define PUGIXML_NOEXCEPT
+#endif
+
// If C++ is 2011 or higher, add 'override' qualifiers
#ifndef PUGIXML_OVERRIDE
# if __cplusplus >= 201103
@@ -1140,8 +1154,8 @@ namespace pugi
#ifdef PUGIXML_HAS_MOVE
// Move semantics support
- xpath_variable_set(xpath_variable_set&& rhs);
- xpath_variable_set& operator=(xpath_variable_set&& rhs);
+ xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
+ xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
#endif
// Add a new variable or get the existing one, if the types match
@@ -1184,8 +1198,8 @@ namespace pugi
#ifdef PUGIXML_HAS_MOVE
// Move semantics support
- xpath_query(xpath_query&& rhs);
- xpath_query& operator=(xpath_query&& rhs);
+ xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
+ xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
#endif
// Get query expression return type
@@ -1325,8 +1339,8 @@ namespace pugi
#ifdef PUGIXML_HAS_MOVE
// Move semantics support
- xpath_node_set(xpath_node_set&& rhs);
- xpath_node_set& operator=(xpath_node_set&& rhs);
+ xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
+ xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
#endif
// Get collection type
@@ -1360,7 +1374,7 @@ namespace pugi
xpath_node* _end;
void _assign(const_iterator begin, const_iterator end, type_t type);
- void _move(xpath_node_set& rhs);
+ void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
};
#endif