summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-10-25 20:40:04 +1100
committerMaxime Coste <mawww@kakoune.org>2023-10-25 20:40:04 +1100
commit96884193ddad76530a09a1b095180b0ca8257b7c (patch)
treeb218d628c370dffeb77a02e1e0bfcdbf0173af42 /src
parentd1c8622dc7ac1d0e2ec07fa7034e4396dffb244f (diff)
Remove redundant comparison operators
Since C++20 (a != b) get automatically rewritten as !(a == b) if the != operator does not exist.
Diffstat (limited to 'src')
-rw-r--r--src/color.hh5
-rw-r--r--src/context.hh2
-rw-r--r--src/face.hh5
-rw-r--r--src/file.hh5
-rw-r--r--src/flags.hh1
-rw-r--r--src/hash_map.hh6
-rw-r--r--src/insert_completer.hh5
-rw-r--r--src/memory.hh7
-rw-r--r--src/option.hh5
-rw-r--r--src/optional.hh2
-rw-r--r--src/parameters_parser.hh5
-rw-r--r--src/range.hh4
-rw-r--r--src/ranges.hh17
-rw-r--r--src/regex.hh8
-rw-r--r--src/selection.hh1
-rw-r--r--src/string.hh10
-rw-r--r--src/string_utils.hh2
-rw-r--r--src/terminal_ui.cc1
-rw-r--r--src/utf8_iterator.hh4
19 files changed, 6 insertions, 89 deletions
diff --git a/src/color.hh b/src/color.hh
index 85babd98..151547c4 100644
--- a/src/color.hh
+++ b/src/color.hh
@@ -69,11 +69,6 @@ constexpr bool operator==(Color lhs, Color rhs)
lhs.r == rhs.r and lhs.g == rhs.g and lhs.b == rhs.b;
}
-constexpr bool operator!=(Color lhs, Color rhs)
-{
- return not (lhs == rhs);
-}
-
Color str_to_color(StringView color);
String to_string(Color color);
diff --git a/src/context.hh b/src/context.hh
index f6f00b80..846855a2 100644
--- a/src/context.hh
+++ b/src/context.hh
@@ -33,8 +33,6 @@ struct JumpList
return lhs.m_jumps == rhs.m_jumps and lhs.m_current == rhs.m_current;
}
- friend bool operator!=(const JumpList& lhs, const JumpList& rhs) { return not (lhs == rhs); }
-
size_t current_index() const { return m_current; }
ConstArrayView<SelectionList> get_as_list() const { return m_jumps; }
diff --git a/src/face.hh b/src/face.hh
index ce544116..bbe8031a 100644
--- a/src/face.hh
+++ b/src/face.hh
@@ -41,11 +41,6 @@ struct Face
lhs.attributes == rhs.attributes;
}
- friend constexpr bool operator!=(const Face& lhs, const Face& rhs)
- {
- return not (lhs == rhs);
- }
-
friend constexpr size_t hash_value(const Face& val)
{
return hash_values(val.fg, val.bg, val.underline, val.attributes);
diff --git a/src/file.hh b/src/file.hh
index 65abd3c8..cfc68ac2 100644
--- a/src/file.hh
+++ b/src/file.hh
@@ -103,11 +103,6 @@ constexpr bool operator==(const timespec& lhs, const timespec& rhs)
return lhs.tv_sec == rhs.tv_sec and lhs.tv_nsec == rhs.tv_nsec;
}
-constexpr bool operator!=(const timespec& lhs, const timespec& rhs)
-{
- return not (lhs == rhs);
-}
-
enum class FilenameFlags
{
None = 0,
diff --git a/src/flags.hh b/src/flags.hh
index 6d4764f3..4cecd5a5 100644
--- a/src/flags.hh
+++ b/src/flags.hh
@@ -39,7 +39,6 @@ struct TestableFlags
constexpr operator UnderlyingType<Flags>() const { return (UnderlyingType<Flags>)value; }
constexpr bool operator==(const TestableFlags<Flags>& other) const { return value == other.value; }
- constexpr bool operator!=(const TestableFlags<Flags>& other) const { return value != other.value; }
};
template<WithBitOps Flags>
diff --git a/src/hash_map.hh b/src/hash_map.hh
index 4c1f258f..f5bc9412 100644
--- a/src/hash_map.hh
+++ b/src/hash_map.hh
@@ -354,12 +354,6 @@ struct HashMap
return size() == other.size() and std::equal(begin(), end(), other.begin());
}
- template<MemoryDomain otherDomain>
- constexpr bool operator!=(const HashMap<Key, Value, otherDomain, Container>& other) const
- {
- return not (*this == other);
- }
-
private:
static auto& item_value(auto& item)
{
diff --git a/src/insert_completer.hh b/src/insert_completer.hh
index 269368d5..d7fb5967 100644
--- a/src/insert_completer.hh
+++ b/src/insert_completer.hh
@@ -28,9 +28,6 @@ struct InsertCompleterDesc
bool operator==(const InsertCompleterDesc& other) const
{ return mode == other.mode and param == other.param; }
- bool operator!=(const InsertCompleterDesc& other) const
- { return not (*this == other); }
-
Mode mode;
Optional<String> param;
};
@@ -62,7 +59,7 @@ struct InsertCompletion
DisplayLine menu_entry;
bool operator==(const Candidate& other) const { return completion == other.completion; }
- bool operator<(const Candidate& other) const { return completion < other.completion; }
+ auto operator<=>(const Candidate& other) const { return completion <=> other.completion; }
};
using CandidateList = Vector<Candidate, MemoryDomain::Completion>;
diff --git a/src/memory.hh b/src/memory.hh
index 6ae64fe9..8eff2d54 100644
--- a/src/memory.hh
+++ b/src/memory.hh
@@ -132,13 +132,6 @@ constexpr bool operator==(const Allocator<T1, d1>&, const Allocator<T2, d2>&)
return d1 == d2;
}
-template<typename T1, MemoryDomain d1, typename T2, MemoryDomain d2>
-constexpr bool operator!=(const Allocator<T1, d1>&, const Allocator<T2, d2>&)
-{
- return d1 != d2;
-}
-
-
constexpr MemoryDomain memory_domain(Meta::AnyType) { return MemoryDomain::Undefined; }
template<typename T>
diff --git a/src/option.hh b/src/option.hh
index a04b235c..d7f75431 100644
--- a/src/option.hh
+++ b/src/option.hh
@@ -62,11 +62,6 @@ struct PrefixedList
{
return lhs.prefix == rhs.prefix and lhs.list == rhs.list;
}
-
- friend bool operator!=(const PrefixedList& lhs, const PrefixedList& rhs)
- {
- return not (lhs == rhs);
- }
};
template<typename T>
diff --git a/src/optional.hh b/src/optional.hh
index 81dd15cf..d50c24f0 100644
--- a/src/optional.hh
+++ b/src/optional.hh
@@ -57,8 +57,6 @@ public:
(not m_valid or m_value == other.m_value);
}
- bool operator!=(const Optional& other) const { return !(*this == other); }
-
template<typename... Args>
T& emplace(Args&&... args)
{
diff --git a/src/parameters_parser.hh b/src/parameters_parser.hh
index 86ba88ce..c11dc501 100644
--- a/src/parameters_parser.hh
+++ b/src/parameters_parser.hh
@@ -117,11 +117,6 @@ struct ParametersParser
return m_index == other.m_index;
}
- bool operator!=(const iterator& other) const
- {
- return not (*this == other);
- }
-
private:
const ParametersParser& m_parser;
size_t m_index;
diff --git a/src/range.hh b/src/range.hh
index 21443b51..696e5010 100644
--- a/src/range.hh
+++ b/src/range.hh
@@ -15,10 +15,6 @@ struct Range
return lhs.begin == rhs.begin and lhs.end == rhs.end;
}
- friend bool operator!=(const Range& lhs, const Range& rhs)
- {
- return not (lhs == rhs);
- }
friend size_t hash_value(const Range& range)
{
diff --git a/src/ranges.hh b/src/ranges.hh
index 816d6efb..bf55ca09 100644
--- a/src/ranges.hh
+++ b/src/ranges.hh
@@ -145,11 +145,6 @@ struct FilterView
return lhs.m_it == rhs.m_it;
}
- friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
- {
- return not (lhs == rhs);
- }
-
const RangeIt& base() const { return m_it; }
private:
@@ -205,11 +200,6 @@ struct EnumerateView
return lhs.m_it == rhs.m_it;
}
- friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
- {
- return not (lhs == rhs);
- }
-
const RangeIt& base() const { return m_it; }
private:
@@ -264,7 +254,6 @@ struct TransformView
Iterator operator-(difference_type diff) const { return {*m_transform, m_it - diff}; }
friend bool operator==(const Iterator& lhs, const Iterator& rhs) { return lhs.m_it == rhs.m_it; }
- friend bool operator!=(const Iterator& lhs, const Iterator& rhs) { return not (lhs == rhs); }
friend difference_type operator-(const Iterator& lhs, const Iterator& rhs) { return lhs.m_it - rhs.m_it; }
RangeIt base() const { return m_it; }
@@ -350,7 +339,6 @@ struct SplitView
Iterator operator++(int) { auto copy = *this; advance(); return copy; }
bool operator==(const Iterator& other) const { return pos == other.pos and done == other.done; }
- bool operator!=(const Iterator& other) const { return pos != other.pos or done != other.done; }
ValueType operator*() { return {pos, (not include_separator or sep == end) ? sep : sep + 1}; }
@@ -528,11 +516,6 @@ struct ConcatView
lhs.m_it2 == rhs.m_it2;
}
- friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
- {
- return not (lhs == rhs);
- }
-
private:
bool is2() const { return m_it1 == m_end1; }
diff --git a/src/regex.hh b/src/regex.hh
index d735aaf0..97ba8ebd 100644
--- a/src/regex.hh
+++ b/src/regex.hh
@@ -16,7 +16,6 @@ public:
explicit Regex(StringView re, RegexCompileFlags flags = RegexCompileFlags::None);
bool empty() const { return m_str.empty(); }
bool operator==(const Regex& other) const { return m_str == other.m_str; }
- bool operator!=(const Regex& other) const { return m_str != other.m_str; }
const String& str() const { return m_str; }
@@ -62,7 +61,6 @@ struct MatchResults
SubMatch operator*() const { return {*m_it, *(m_it+1)}; }
friend bool operator==(const iterator& lhs, const iterator& rhs) { return lhs.m_it == rhs.m_it; }
- friend bool operator!=(const iterator& lhs, const iterator& rhs) { return lhs.m_it != rhs.m_it; }
private:
It m_it;
@@ -90,11 +88,6 @@ struct MatchResults
return lhs.m_values == rhs.m_values;
}
- friend bool operator!=(const MatchResults& lhs, const MatchResults& rhs)
- {
- return not (lhs == rhs);
- }
-
void swap(MatchResults& other)
{
m_values.swap(other.m_values);
@@ -192,7 +185,6 @@ struct RegexIterator
It& operator++() { m_valid = m_base.next(); return *this; }
bool operator==(Sentinel) const { return not m_valid; }
- bool operator!=(Sentinel) const { return m_valid; }
RegexIterator& m_base;
bool m_valid;
diff --git a/src/selection.hh b/src/selection.hh
index 7794e093..bd179322 100644
--- a/src/selection.hh
+++ b/src/selection.hh
@@ -127,7 +127,6 @@ struct SelectionList
size_t size() const { return m_selections.size(); }
bool operator==(const SelectionList& other) const { return m_buffer == other.m_buffer and m_selections == other.m_selections; }
- bool operator!=(const SelectionList& other) const { return not ((*this) == other); }
void sort();
void merge_overlapping();
diff --git a/src/string.hh b/src/string.hh
index 9a7e39f0..ec199d4c 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -341,14 +341,10 @@ inline bool operator==(const StringView& lhs, const StringView& rhs)
std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
-[[gnu::always_inline]]
-inline bool operator!=(const StringView& lhs, const StringView& rhs)
-{ return not (lhs == rhs); }
-
-inline bool operator<(const StringView& lhs, const StringView& rhs)
+inline auto operator<=>(const StringView& lhs, const StringView& rhs)
{
- return std::lexicographical_compare(lhs.begin(), lhs.end(),
- rhs.begin(), rhs.end());
+ return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
}
inline String operator"" _str(const char* str, size_t)
diff --git a/src/string_utils.hh b/src/string_utils.hh
index 13d15018..3cd7c825 100644
--- a/src/string_utils.hh
+++ b/src/string_utils.hh
@@ -82,8 +82,6 @@ struct WrapView
Iterator operator++(int) { auto copy = *this; ++(*this); return copy; }
bool operator==(Iterator other) const { return m_remaining == other.m_remaining and m_current == other.m_current; }
- bool operator!=(Iterator other) const { return not (*this == other); }
-
StringView operator*() { return m_current; }
private:
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index 86b44ce3..2b3ce073 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -69,7 +69,6 @@ struct TerminalUI::Window::Line
}
friend bool operator==(const Atom& lhs, const Atom& rhs) { return lhs.text == rhs.text and lhs.skip == rhs.skip and lhs.face == rhs.face; }
- friend bool operator!=(const Atom& lhs, const Atom& rhs) { return not (lhs == rhs); }
friend size_t hash_value(const Atom& atom) { return hash_values(atom.text, atom.skip, atom.face); }
};
diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh
index 4fd34f54..e17c0c90 100644
--- a/src/utf8_iterator.hh
+++ b/src/utf8_iterator.hh
@@ -100,12 +100,12 @@ public:
}
bool operator==(const iterator& other) const noexcept { return m_it == other.m_it; }
- auto operator<=> (const iterator& other) const noexcept { return m_it <=> other.m_it; }
+ auto operator<=>(const iterator& other) const noexcept { return m_it <=> other.m_it; }
template<typename T>
requires std::is_same_v<T, BaseIt> or std::is_same_v<T, Sentinel>
bool operator==(const T& other) const noexcept { return m_it == other; }
- auto operator<=> (const BaseIt& other) const noexcept { return m_it <=> other; }
+ auto operator<=>(const BaseIt& other) const noexcept { return m_it <=> other; }
DifferenceType operator-(const iterator& other) const noexcept(noexcept_policy)
{