@@ -51,29 +51,24 @@ class Array {
5151
5252public:
5353 struct ConstIterator {
54- _FORCE_INLINE_ const Variant &operator *() const ;
55- _FORCE_INLINE_ const Variant *operator ->() const ;
54+ _FORCE_INLINE_ const Variant &operator *() const { return *element_ptr; }
55+ _FORCE_INLINE_ const Variant *operator ->() const { return element_ptr; }
5656
5757 _FORCE_INLINE_ ConstIterator &operator ++();
5858 _FORCE_INLINE_ ConstIterator &operator --();
5959
6060 _FORCE_INLINE_ bool operator ==(const ConstIterator &p_other) const { return element_ptr == p_other.element_ptr ; }
6161 _FORCE_INLINE_ bool operator !=(const ConstIterator &p_other) const { return element_ptr != p_other.element_ptr ; }
6262
63+ ConstIterator () = default ;
64+
6365 _FORCE_INLINE_ ConstIterator (const Variant *p_element_ptr) :
6466 element_ptr(p_element_ptr) {}
65- _FORCE_INLINE_ ConstIterator () {}
66- _FORCE_INLINE_ ConstIterator (const ConstIterator &p_other) :
67- element_ptr(p_other.element_ptr) {}
68-
69- _FORCE_INLINE_ ConstIterator &operator =(const ConstIterator &p_other) {
70- element_ptr = p_other.element_ptr ;
71- return *this ;
72- }
7367
7468 private:
7569 const Variant *element_ptr = nullptr ;
7670 };
71+ static_assert (std::is_trivially_copyable_v<ConstIterator>, " ConstIterator must be trivially copyable" );
7772
7873 struct Iterator {
7974 _FORCE_INLINE_ Variant &operator *() const ;
@@ -85,26 +80,18 @@ class Array {
8580 _FORCE_INLINE_ bool operator ==(const Iterator &p_other) const { return element_ptr == p_other.element_ptr ; }
8681 _FORCE_INLINE_ bool operator !=(const Iterator &p_other) const { return element_ptr != p_other.element_ptr ; }
8782
88- _FORCE_INLINE_ Iterator (Variant *p_element_ptr, Variant *p_read_only = nullptr ) :
89- element_ptr(p_element_ptr), read_only(p_read_only) {}
90- _FORCE_INLINE_ Iterator () {}
91- _FORCE_INLINE_ Iterator (const Iterator &p_other) :
92- element_ptr(p_other.element_ptr), read_only(p_other.read_only) {}
83+ _FORCE_INLINE_ operator ConstIterator () const { return ConstIterator (element_ptr); }
9384
94- _FORCE_INLINE_ Iterator &operator =(const Iterator &p_other) {
95- element_ptr = p_other.element_ptr ;
96- read_only = p_other.read_only ;
97- return *this ;
98- }
85+ Iterator () = default ;
9986
100- operator ConstIterator () const {
101- return ConstIterator (element_ptr);
102- }
87+ _FORCE_INLINE_ Iterator (Variant *p_element_ptr, Variant *p_read_only = nullptr ) :
88+ element_ptr(p_element_ptr), read_only(p_read_only) {}
10389
10490 private:
10591 Variant *element_ptr = nullptr ;
10692 Variant *read_only = nullptr ;
10793 };
94+ static_assert (std::is_trivially_copyable_v<Iterator>, " Iterator must be trivially copyable" );
10895
10996 Iterator begin ();
11097 Iterator end ();
0 commit comments