mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
4296425bd8
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
52 lines
953 B
C++
52 lines
953 B
C++
/*
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Array.h>
|
|
#include <AK/ByteBuffer.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/Types.h>
|
|
|
|
#ifdef KERNEL
|
|
# include <Kernel/KString.h>
|
|
#else
|
|
# include <AK/String.h>
|
|
#endif
|
|
|
|
namespace AK {
|
|
|
|
class UUID {
|
|
public:
|
|
enum class Endianness {
|
|
Mixed,
|
|
Little
|
|
};
|
|
|
|
UUID() = default;
|
|
UUID(Array<u8, 16> uuid_buffer);
|
|
UUID(StringView, Endianness endianness = Endianness::Little);
|
|
~UUID() = default;
|
|
|
|
bool operator==(const UUID&) const = default;
|
|
|
|
#ifdef KERNEL
|
|
ErrorOr<NonnullOwnPtr<Kernel::KString>> to_string() const;
|
|
#else
|
|
String to_string() const;
|
|
#endif
|
|
bool is_zero() const;
|
|
|
|
private:
|
|
void convert_string_view_to_little_endian_uuid(StringView);
|
|
void convert_string_view_to_mixed_endian_uuid(StringView);
|
|
|
|
Array<u8, 16> m_uuid_buffer {};
|
|
};
|
|
|
|
}
|
|
|
|
using AK::UUID;
|