From 576a1a69408e5f8c0ef1c6ba5841d04a9b0db853 Mon Sep 17 00:00:00 2001 From: halx99 Date: Wed, 26 Oct 2022 23:17:48 +0800 Subject: [PATCH] Improve ax::Vector compiler compatible, also fix #933 --- core/base/CCVector.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/base/CCVector.h b/core/base/CCVector.h index 71e4977826..a330a7c5b8 100644 --- a/core/base/CCVector.h +++ b/core/base/CCVector.h @@ -108,24 +108,24 @@ public: const_reverse_iterator crend() const { return _data.crend(); } /** Constructor. */ - Vector() : _data() + Vector() : _data() { - static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); } /** * Constructor with a capacity. * @param capacity Capacity of the Vector. */ - explicit Vector(ssize_t capacity) : _data() + explicit Vector(ssize_t capacity) : _data() { - static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); AXLOGINFO("In the default constructor with capacity of Vector."); reserve(capacity); } /** Constructor with initializer list. */ - Vector(std::initializer_list list) + Vector(std::initializer_list list) { for (auto&& element : list) { @@ -134,31 +134,31 @@ public: } /** Destructor. */ - ~Vector() + ~Vector() { AXLOGINFO("In the destructor of Vector."); clear(); } /** Copy constructor. */ - Vector(const Vector& other) + Vector(const Vector& other) { - static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); AXLOGINFO("In the copy constructor!"); _data = other._data; addRefForAllObjects(); } /** Constructor with std::move semantic. */ - Vector(Vector&& other) + Vector(Vector&& other) { - static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); + static_assert(std::is_convertible::value, "Invalid Type for ax::Vector!"); AXLOGINFO("In the move constructor of Vector!"); _data = std::move(other._data); } /** Copy assignment operator. */ - Vector& operator=(const Vector& other) + Vector& operator=(const Vector& other) { if (this != &other) { @@ -171,7 +171,7 @@ public: } /** Copy assignment operator with std::move semantic. */ - Vector& operator=(Vector&& other) + Vector& operator=(Vector&& other) { if (this != &other) { @@ -217,7 +217,7 @@ public: /** @brief Returns whether the Vector is empty (i.e. whether its size is 0). * @note This function does not modify the container in any way. To clear the content of a vector, see - * Vector::clear. + * Vector::clear. */ bool empty() const { return _data.empty(); } @@ -284,7 +284,7 @@ public: * @param other The vector to be compared. * @return True if two vectors are equal, false if not. */ - bool equals(const Vector& other) const + bool equals(const Vector& other) const { ssize_t s = this->size(); if (s != other.size()) @@ -311,7 +311,7 @@ public: } /** Push all elements of an existing Vector to the end of current Vector. */ - void pushBack(const Vector& other) + void pushBack(const Vector& other) { for (const auto& obj : other) {