mirror of
https://github.com/RGBCube/serenity
synced 2026-01-17 08:31:00 +00:00
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
50 lines
879 B
C++
50 lines
879 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/String.h>
|
|
#include <AK/Types.h>
|
|
#include <AK/URL.h>
|
|
|
|
namespace Spreadsheet {
|
|
|
|
class Sheet;
|
|
|
|
struct Position {
|
|
Position() = default;
|
|
|
|
Position(size_t column, size_t row)
|
|
: column(column)
|
|
, row(row)
|
|
, m_hash(pair_int_hash(column, row))
|
|
{
|
|
}
|
|
|
|
ALWAYS_INLINE u32 hash() const
|
|
{
|
|
if (m_hash == 0)
|
|
return m_hash = int_hash(column * 65537 + row);
|
|
|
|
return m_hash;
|
|
}
|
|
|
|
bool operator==(Position const& other) const
|
|
{
|
|
return row == other.row && column == other.column;
|
|
}
|
|
|
|
String to_cell_identifier(Sheet const& sheet) const;
|
|
URL to_url(Sheet const& sheet) const;
|
|
|
|
size_t column { 0 };
|
|
size_t row { 0 };
|
|
|
|
private:
|
|
mutable u32 m_hash { 0 };
|
|
};
|
|
|
|
}
|