1414#include " ns3/attribute-helper.h"
1515#include " ns3/attribute.h"
1616
17+ #include < array>
18+ #include < compare>
1719#include < ostream>
1820#include < stdint.h>
1921
@@ -149,39 +151,21 @@ class Mac48Address
149151 */
150152 typedef void (*TracedCallback)(Mac48Address value);
151153
152- private:
153- /* *
154- * @brief Return the Type of address.
155- * @return type of address
156- */
157- static uint8_t GetType ();
158-
159- /* *
160- * @brief Equal to operator.
161- *
162- * @param a the first operand
163- * @param b the first operand
164- * @returns true if the operands are equal
165- */
166- friend bool operator ==(const Mac48Address& a, const Mac48Address& b);
167-
168154 /* *
169- * @brief Not equal to operator.
155+ * Spaceship comparison operator. All the other comparison operators
156+ * are automatically generated from this one.
170157 *
171- * @param a the first operand
172- * @param b the first operand
173- * @returns true if the operands are not equal
158+ * @param other address to compare to this one
159+ * @returns The result of the comparison.
174160 */
175- friend bool operator != (const Mac48Address& a, const Mac48Address& b) ;
161+ constexpr std::strong_ordering operator <=> (const Mac48Address& other) const = default ;
176162
163+ private:
177164 /* *
178- * @brief Less than operator.
179- *
180- * @param a the first operand
181- * @param b the first operand
182- * @returns true if the operand a is less than operand b
165+ * @brief Return the Type of address.
166+ * @return type of address
183167 */
184- friend bool operator <( const Mac48Address& a, const Mac48Address& b );
168+ static uint8_t GetType ( );
185169
186170 /* *
187171 * @brief Stream insertion operator.
@@ -201,30 +185,12 @@ class Mac48Address
201185 */
202186 friend std::istream& operator >>(std::istream& is, Mac48Address& address);
203187
204- static uint64_t m_allocationIndex; // !< Address allocation index
205- uint8_t m_address[ 6 ]{ 0 }; // !< Address value
188+ static uint64_t m_allocationIndex; // !< Address allocation index
189+ std::array< uint8_t , 6 > m_address{}; // !< Address value
206190};
207191
208192ATTRIBUTE_HELPER_HEADER (Mac48Address);
209193
210- inline bool
211- operator ==(const Mac48Address& a, const Mac48Address& b)
212- {
213- return memcmp (a.m_address , b.m_address , 6 ) == 0 ;
214- }
215-
216- inline bool
217- operator !=(const Mac48Address& a, const Mac48Address& b)
218- {
219- return memcmp (a.m_address , b.m_address , 6 ) != 0 ;
220- }
221-
222- inline bool
223- operator <(const Mac48Address& a, const Mac48Address& b)
224- {
225- return memcmp (a.m_address , b.m_address , 6 ) < 0 ;
226- }
227-
228194std::ostream& operator <<(std::ostream& os, const Mac48Address& address);
229195std::istream& operator >>(std::istream& is, Mac48Address& address);
230196
0 commit comments