Commit eef5b582 authored by Max Kellermann's avatar Max Kellermann

tag/Tag: add "noexcept"

parent 1de68b72
...@@ -40,7 +40,7 @@ Tag::Clear() noexcept ...@@ -40,7 +40,7 @@ Tag::Clear() noexcept
num_items = 0; num_items = 0;
} }
Tag::Tag(const Tag &other) Tag::Tag(const Tag &other) noexcept
:duration(other.duration), has_playlist(other.has_playlist), :duration(other.duration), has_playlist(other.has_playlist),
num_items(other.num_items), num_items(other.num_items),
items(nullptr) items(nullptr)
...@@ -64,7 +64,7 @@ Tag::Merge(const Tag &base, const Tag &add) noexcept ...@@ -64,7 +64,7 @@ Tag::Merge(const Tag &base, const Tag &add) noexcept
} }
std::unique_ptr<Tag> std::unique_ptr<Tag>
Tag::Merge(std::unique_ptr<Tag> base, std::unique_ptr<Tag> add) Tag::Merge(std::unique_ptr<Tag> base, std::unique_ptr<Tag> add) noexcept
{ {
if (add == nullptr) if (add == nullptr)
return base; return base;
......
...@@ -56,9 +56,9 @@ struct Tag { ...@@ -56,9 +56,9 @@ struct Tag {
*/ */
Tag() = default; Tag() = default;
Tag(const Tag &other); Tag(const Tag &other) noexcept;
Tag(Tag &&other) Tag(Tag &&other) noexcept
:duration(other.duration), has_playlist(other.has_playlist), :duration(other.duration), has_playlist(other.has_playlist),
num_items(other.num_items), items(other.items) { num_items(other.num_items), items(other.items) {
other.items = nullptr; other.items = nullptr;
...@@ -68,13 +68,13 @@ struct Tag { ...@@ -68,13 +68,13 @@ struct Tag {
/** /**
* Free the tag object and all its items. * Free the tag object and all its items.
*/ */
~Tag() { ~Tag() noexcept {
Clear(); Clear();
} }
Tag &operator=(const Tag &other) = delete; Tag &operator=(const Tag &other) = delete;
Tag &operator=(Tag &&other) { Tag &operator=(Tag &&other) noexcept {
duration = other.duration; duration = other.duration;
has_playlist = other.has_playlist; has_playlist = other.has_playlist;
MoveItemsFrom(std::move(other)); MoveItemsFrom(std::move(other));
...@@ -126,7 +126,7 @@ struct Tag { ...@@ -126,7 +126,7 @@ struct Tag {
* @return a newly allocated tag * @return a newly allocated tag
*/ */
static std::unique_ptr<Tag> Merge(std::unique_ptr<Tag> base, static std::unique_ptr<Tag> Merge(std::unique_ptr<Tag> base,
std::unique_ptr<Tag> add); std::unique_ptr<Tag> add) noexcept;
/** /**
* Returns the first value of the specified tag type, or * Returns the first value of the specified tag type, or
...@@ -155,52 +155,52 @@ struct Tag { ...@@ -155,52 +155,52 @@ struct Tag {
friend struct Tag; friend struct Tag;
const TagItem *const*cursor; const TagItem *const*cursor;
constexpr const_iterator(const TagItem *const*_cursor) constexpr const_iterator(const TagItem *const*_cursor) noexcept
:cursor(_cursor) {} :cursor(_cursor) {}
public: public:
constexpr const TagItem &operator*() const { constexpr const TagItem &operator*() const noexcept {
return **cursor; return **cursor;
} }
constexpr const TagItem *operator->() const { constexpr const TagItem *operator->() const noexcept {
return *cursor; return *cursor;
} }
const_iterator &operator++() { const_iterator &operator++() noexcept {
++cursor; ++cursor;
return *this; return *this;
} }
const_iterator operator++(int) { const_iterator operator++(int) noexcept {
auto result = cursor++; auto result = cursor++;
return const_iterator{result}; return const_iterator{result};
} }
const_iterator &operator--() { const_iterator &operator--() noexcept {
--cursor; --cursor;
return *this; return *this;
} }
const_iterator operator--(int) { const_iterator operator--(int) noexcept {
auto result = cursor--; auto result = cursor--;
return const_iterator{result}; return const_iterator{result};
} }
constexpr bool operator==(const_iterator other) const { constexpr bool operator==(const_iterator other) const noexcept {
return cursor == other.cursor; return cursor == other.cursor;
} }
constexpr bool operator!=(const_iterator other) const { constexpr bool operator!=(const_iterator other) const noexcept {
return cursor != other.cursor; return cursor != other.cursor;
} }
}; };
const_iterator begin() const { const_iterator begin() const noexcept {
return const_iterator{items}; return const_iterator{items};
} }
const_iterator end() const { const_iterator end() const noexcept {
return const_iterator{items + num_items}; return const_iterator{items + num_items};
} }
}; };
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <cppunit/ui/text/TestRunner.h> #include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/HelperMacros.h>
Tag::Tag(const Tag &) {} Tag::Tag(const Tag &) noexcept {}
void Tag::Clear() noexcept {} void Tag::Clear() noexcept {}
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment